Here is the code, I'm only including the 2 functions, one is creating a thread and starts it, the other just does some task and updates the status strips
private void _doSomething()
{
try
{
_thread = new Thread(DoSomething);
_thread.Start();
while (_thread.ThreadState == System.Threading.ThreadState.Running)
{
Application.DoEvents();
this.Refresh();
Thread.Sleep(50);
}
_thread.Join();
}
catch (Exception ex)
{ MessageBox.Show (ex.ToString()); }
finally
{
_thread = null;
}
}
private void DoSomething()
{
string _result = string.Empty;
this.toolStripStatusLabel5.Text = "doing something.....";
this.toolStripStatusLabel5.Image = workingImg;
Something.Utilities _utilities = new Something.Utilities();
_result = _utilities.DoStuff(_pfsui, _pfspw, _pfsSocket, _pfsHost, _pfsSendPort, _sn, _an);
if (_result.Contains("OK"))
{
_utilities = null;
}
else
{ _utilities = null; }
this.toolStripStatusLabel5.Text = string.Empty;
this.toolStripStatusLabel5.Image = null;
}
Now, while the GUI is up and idle the seconds in the time display in the status strip are ticking. However when the _doSomething function being called the time display freezes for the duration of the function and also the "workingImg" which is the gif is not being animated.
I don't know what I'm doing wrong here. This is such a simple app that I don't want to redo it with the BackGroundWorker class.
thanks

New Topic/Question
Reply




MultiQuote





|