Hi TS,
> the code doesn't continue to execute the rest of the method
ShowDialog() is a blocking call(its not really but it pretends to be).
When you call ShowDialog, your going to sit at that point waiting for
the dialog to close, returning a DialogResult.
> instead it starts back at the top again
Your code isn't starting at the top of the function. What you are
seeing is another call thats just been made.
As a test, in your timer function just keep creating new forms, dont
close them. Each time Call showdialog, then show a message box.
If you wait untill 5 forms are all showing at the same time, you won't
have seen any message boxs. As you close all of them, you will see 5
message boxs.
> After the 2nd time thru the method, everything works as expected. Why
is this?
It works the second time through because you designed your state
machine well. The problem is your code is designed to run in a loop,
and the timer event that your using is close to a loop, but it's not.
would this work for you instead?
private EventHandler SomeCallback;
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
this.SomeCallback = new EventHandler(this.SomeEventHandler);
new System.Threading.Thread(new
System.Threading.ThreadStart(SomeThread)).Start();
}
public void SomeThread()
{
while ( true )
{
string status = this.MyController.GetApplicantStatus();
if( status == "H" ) //Hold
{
if(this.pause == null)
{
this.BeginInvoke(SomeCallback);
}
}
else if( status == "T" ) //Terminated
{
if(this.pause != null)
pause.Close();
this.terminateTimer.Stop();
this.MyController.TerminateSession();
}
else
{
if(this.pause != null)
{
pause.Close();
pause.Dispose();
}
}
string x="asdfasdf";
System.Threading.Thread.Sleep(5000); //TerminateTimer.Interval
}
}
private void SomeEventHandler(object s, System.EventArgs e)
{
pause = new Pause();
pause.ShowDialog();
}
Kind Regards,
Jerron
TS - 17 Jan 2005 13:01 GMT
thanks, i think my problem is now fixed!
> Hi TS,
>
[quoted text clipped - 78 lines]
> Kind Regards,
> Jerron