473,614 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[Q]Multi-Threaded Splash Screen not displaying first update.

Dear Group,

I am attempting to write a "splash" and "status" Form using a second
thread.

I wish to use this Form to display status information to the user when
I do CPU intensive work in my GUI during startup. I wish to also use
the same Form after startup as well if I do something CPU intensive.

I have developed a multi-threaded application however the very first
status update does not always display. It sometimes appears – which I
am assuming is to do with the interaction of my two threads.

Could anyone comment on what I have missed that causes the "Startup
Point 1" and "Running Point 1" status labels to sometimes display and
others not.

I have included the following cutdown example of what I am doing.
There are two files ApplicationLoad er.cs and MainApplication Form.cs.
Run the application to see the startup screen and press the button to
see the running version. Note the first status information label
shown.

Any comments would be most appreciated.

Thanks

Stuart

------Start ApplicationLoad er.cs------------
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Threadin g;

namespace startupscreen
{
public class statusInformati onForm : System.Windows. Forms.Form
{
private System.Windows. Forms.Label statusInformati on;
private System.Windows. Forms.Label statusTitleLabe l;

private System.Componen tModel.Containe r components = null;

public statusInformati onForm()
{
InitializeCompo nent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

private string theStatusInfo = String.Empty;
public string StatusInfo
{
set
{
theStatusInfo = value;
updateStatusTex t();
}
get
{
return theStatusInfo;
}
}

public void updateStatusTex t()
{
try
{
if (this.InvokeReq uired)
{
this.Invoke(new MethodInvoker(t his.updateStatu sText));
return;
}

statusInformati on.Text = theStatusInfo;
}
catch (Exception e)
{
}
}
#region Windows Form Designer generated code
private void InitializeCompo nent()
{
this.statusInfo rmation = new System.Windows. Forms.Label();
this.statusTitl eLabel = new System.Windows. Forms.Label();
this.SuspendLay out();
//
// statusInformati on
//
this.statusInfo rmation.Locatio n = new System.Drawing. Point(80, 40);
this.statusInfo rmation.Name = "statusInformat ion";
this.statusInfo rmation.Size = new System.Drawing. Size(200, 16);
this.statusInfo rmation.TabInde x = 1;
//
// statusTitleLabe l
//
this.statusTitl eLabel.Location = new System.Drawing. Point(16, 40);
this.statusTitl eLabel.Name = "statusTitleLab el";
this.statusTitl eLabel.Size = new System.Drawing. Size(48, 16);
this.statusTitl eLabel.TabIndex = 2;
this.statusTitl eLabel.Text = "Status:";
//
// statusInformati onForm
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.BackColor = System.Drawing. Color.White;
this.ClientSize = new System.Drawing. Size(300, 94);
this.ControlBox = false;
this.Controls.A dd(this.statusT itleLabel);
this.Controls.A dd(this.statusI nformation);
this.FormBorder Style =
System.Windows. Forms.FormBorde rStyle.FixedSin gle;
this.Name = "statusInformat ionForm";
this.StartPosit ion =
System.Windows. Forms.FormStart Position.Center Screen;
this.ResumeLayo ut(false);

}
#endregion
}

public class ApplicationLoad er
{
[STAThread]
static void Main(string[] args)
{
MainApplication Form mainApplication Form = new
MainApplication Form();
Application.Run (mainApplicatio nForm);
}
}
public class statusInformati onScreen
{
private static statusInformati onForm theStatusInform ationForm =
null;
private static Thread statusInformati onThread = null;

private static void ShowThread()
{
theStatusInform ationForm = new statusInformati onForm();
Application.Run (theStatusInfor mationForm);
}

public static void Show()
{
if (statusInformat ionThread != null)
return;

statusInformati onThread = new Thread(new
ThreadStart(sta tusInformationS creen.ShowThrea d));
statusInformati onThread.IsBack ground = true;
statusInformati onThread.Apartm entState = ApartmentState. STA;
statusInformati onThread.Start( );
}

public static void Close()
{
if (statusInformat ionThread == null || theStatusInform ationForm ==
null)
{
statusInformati onThread = null;
theStatusInform ationForm = null;
return;
}
try
{
theStatusInform ationForm.Invok e(new
MethodInvoker(t heStatusInforma tionForm.Close) );
}
catch (Exception)
{
}
statusInformati onThread = null;
theStatusInform ationForm = null;
}

public static string Status
{
set
{
if (theStatusInfor mationForm == null)
{
return;
}
theStatusInform ationForm.Statu sInfo = value;
}
get
{
if (theStatusInfor mationForm == null)
{
throw new InvalidOperatio nException("For m not visible?");
}
return theStatusInform ationForm.Statu sInfo;
}
}
}
}
------End ApplicationLoad er.cs------------
------Start MainApplication Form.cs--------
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using System.Threadin g;

namespace startupscreen
{
public class MainApplication Form : System.Windows. Forms.Form
{
private System.Windows. Forms.Button Button;
private System.Componen tModel.Containe r components = null;

public MainApplication Form()
{
InitializeCompo nent();

statusInformati onScreen.Show() ;
//
// This status information is not ALWAYS displayed
//
statusInformati onScreen.Status = "Startup Point 1";
System.Threadin g.Thread.Sleep( 2000);

statusInformati onScreen.Status = "Startup Point 2";
System.Threadin g.Thread.Sleep( 2000);

statusInformati onScreen.Status = "Startup Point 3";
System.Threadin g.Thread.Sleep( 2000);

statusInformati onScreen.Close( );
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code

private void InitializeCompo nent()
{
this.Button = new System.Windows. Forms.Button();
this.SuspendLay out();
//
// Button
//
this.Button.Loc ation = new System.Drawing. Point(72, 88);
this.Button.Nam e = "Button";
this.Button.Siz e = new System.Drawing. Size(136, 96);
this.Button.Tab Index = 0;
this.Button.Tex t = "Push Me";
this.Button.Cli ck += new System.EventHan dler(this.butto n_Click);
//
// MainApplication Form
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 266);
this.Controls.A dd(this.Button) ;
this.Name = "MainApplicatio nForm";
this.Text = "My Form";
this.ResumeLayo ut(false);

}
#endregion

protected override void OnLoad(System.E ventArgs e)
{
this.Activate() ;
}

private void button_Click(ob ject sender, System.EventArg s e)
{
statusInformati onScreen.Show() ;
//
// This status information is not ALWAYS displayed
//
statusInformati onScreen.Status = "Running Point 1";
System.Threadin g.Thread.Sleep( 2000);

statusInformati onScreen.Status = "Running Point 2";
System.Threadin g.Thread.Sleep( 2000);

statusInformati onScreen.Status = "Running Point 3";
System.Threadin g.Thread.Sleep( 2000);

statusInformati onScreen.Close( );
}
}
}
------End MainApplication Form.cs--------
Nov 16 '05 #1
0 1808

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
4867
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo
4
4653
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
3862
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
6
8162
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
17846
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
5
5976
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a TIFF to several PNG files this causes a problem, becuase the resulting image is (the page to the far left and a lot of black space surrounding it and a filesize that is larger than needed. Any ideas?
5
3267
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify this? Private Sub cmdPreview_Click() On Error GoTo Err_Handler 'Purpose: Open the report filtered to the items selected in the list box. 'Author: Allen J Browne, 2004. http://allenbrowne.com Dim varItem As Variant 'Selected items
0
2317
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08> *********************************************************************** Context
1
9297
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "PAR.PAR_Status" could not be bound. The multi-part identifier "Salary.New_Salary" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part...
2
4654
by: Aussie Rules | last post by:
Hi, I have a site that Iwant to either display my text in english or french, based on the users prefernces ? I am new to webforms, but I know in winforms, this is pretty easy with a resource file. What is the best way to acheive this with webforms ?
0
8130
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8627
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8579
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8279
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6088
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5540
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4127
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1425
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.