Click here to Skip to main content
15,887,812 members
Home / Discussions / C#
   

C#

 
QuestionCreating .msi file for A windows Service Application Pin
boneyds11-Aug-07 19:10
boneyds11-Aug-07 19:10 
QuestionURGENT!!! Folder security code needed Pin
aravinda77711-Aug-07 18:26
aravinda77711-Aug-07 18:26 
AnswerRe: URGENT!!! Folder security code needed Pin
Expert Coming11-Aug-07 19:58
Expert Coming11-Aug-07 19:58 
QuestionAsk for Windows application implement communication between many clients and one server Pin
liucaihua11-Aug-07 17:09
liucaihua11-Aug-07 17:09 
AnswerRe: Ask for Windows application implement communication between many clients and one server Pin
Ravi Bhavnani11-Aug-07 19:40
professionalRavi Bhavnani11-Aug-07 19:40 
Questionproblem to use thread.Abort() method. Pin
hdv21211-Aug-07 15:01
hdv21211-Aug-07 15:01 
AnswerRe: problem to use thread.Abort() method. Pin
Leslie Sanford11-Aug-07 15:29
Leslie Sanford11-Aug-07 15:29 
AnswerRe: problem to use thread.Abort() method. Pin
S. Senthil Kumar11-Aug-07 15:33
S. Senthil Kumar11-Aug-07 15:33 
Why would you want to abort the thread? Why not make it exit normally using some event signalling mechanism?

That apart, what exactly does the thread do? If all it does is show a form, you're much better off doing it in the UI thread (the thread that Frm_Land_Load runs on) and doing this.Initialize_Data on a different thread. Something like

private void Frm_Land_Load(object sender, EventArgs e)
{
Thread th = new Thread(DoWork);
th.Start();

gu.Show_WaitingForm();
}

private void DoWork()
{
   this.Initialize_Data();
   this.BeginInvoke(new MethodInvoker(CloseWaitingForm), null);
}

private void CloseWaitingForm()
{
   gu.Hide_WaitingForm();
}

This way, when Initialize_Data completes, CloseWaitingForm will be called on the main UI thread, which will hide the waiting form.

This solution assumes that Initialize_Data does not access any controls in the form. If it does, then you'll have to run the waiting form on a different thread. Something like

private void Frm_Land_Load(object sender, EventArgs e)
{
   Thread th = new Thread(gu.Show_WaitingForm);
   th.Start();
   this.Initialize_Data();
   gu.Hide_WaitingForm();
}

class GU
{
  Form f;
  void Show_WaitingForm()
  {
     f = new Form();
     f.ShowDialog();
  }

  void Hide_WaitingForm()
  {
     if (this.InvokeRequired)
     {
       f.BeginInvoke(new MethodInvoker(Hide_WaitingForm), null);
     }
     else
     {
       f.Close();
     }
   }
}


Hope this helps.

Regards
Senthil [MVP - Visual C#]
_____________________________
My Blog | My Articles | My Flickr | WinMacro

QuestionGraphically rich menus (like Microsoft Word) Pin
Muhammad Nauman Yousuf11-Aug-07 12:26
Muhammad Nauman Yousuf11-Aug-07 12:26 
AnswerRe: Graphically rich menus (like Microsoft Word) Pin
Paul Conrad11-Aug-07 16:02
professionalPaul Conrad11-Aug-07 16:02 
AnswerRe: Graphically rich menus (like Microsoft Word) Pin
ekynox12-Aug-07 13:30
ekynox12-Aug-07 13:30 
QuestionUsing Orca to modify a user interface dialog. Pin
steve_rm11-Aug-07 12:08
steve_rm11-Aug-07 12:08 
QuestionAccessing a single class instance from external assemblies Pin
thg97111-Aug-07 10:27
thg97111-Aug-07 10:27 
AnswerRe: Accessing a single class instance from external assemblies Pin
S. Senthil Kumar11-Aug-07 15:39
S. Senthil Kumar11-Aug-07 15:39 
QuestionSimple Q about multidimension array .. plz Help Pin
legend_of_zanado11-Aug-07 9:07
legend_of_zanado11-Aug-07 9:07 
AnswerRe: Simple Q about multidimension array .. plz Help Pin
ScottM111-Aug-07 10:47
ScottM111-Aug-07 10:47 
GeneralRe: Simple Q about multidimension array .. plz Help Pin
Justin.Jones11-Aug-07 18:08
Justin.Jones11-Aug-07 18:08 
GeneralRe: Simple Q about multidimension array .. plz Help Pin
ScottM112-Aug-07 19:56
ScottM112-Aug-07 19:56 
QuestionNeed help with Sqldatareader Pin
erikhjerpe11-Aug-07 6:33
erikhjerpe11-Aug-07 6:33 
AnswerRe: Need help with Sqldatareader Pin
chinaQI11-Aug-07 7:10
chinaQI11-Aug-07 7:10 
GeneralRe: Need help with Sqldatareader Pin
erikhjerpe11-Aug-07 7:26
erikhjerpe11-Aug-07 7:26 
AnswerRe: Need help with Sqldatareader Pin
Colin Angus Mackay11-Aug-07 8:20
Colin Angus Mackay11-Aug-07 8:20 
GeneralRe: Need help with Sqldatareader Pin
erikhjerpe11-Aug-07 8:47
erikhjerpe11-Aug-07 8:47 
GeneralRe: Need help with Sqldatareader Pin
Colin Angus Mackay11-Aug-07 8:54
Colin Angus Mackay11-Aug-07 8:54 
GeneralRe: Need help with Sqldatareader Pin
erikhjerpe11-Aug-07 9:09
erikhjerpe11-Aug-07 9:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.