Hi. I have a form. This form calls thread.
Inside this thread i have while loop:
while ((bufferCount = FileStream.Read(buffer, 0, 64000)) 0
&& !Stop)
{
store += bufferCount;
file.Write(buffer, 0, bufferCount);
// Update information on control
this.Invoke(updDeleg, store);
}
Stop variable is interlocked because i use it also in Dispose method:
protected override void Dispose(bool disposing)
{
Stop = true;
downloadThread.Join();
OpenForms.MainForm.LockDownload(false);
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
The problem is :
I dispose close form and this form is SOMETIMES ( mostly ) lagged. It's
never lagged when i delete this line from while loop:
// Update information on control
this.Invoke(updDeleg, store);
Here this simple invoked method:
private void update(long store)
{
// Update Progressbar here
}
Cant understand why its not working when using Invoke.
For any help i would be grateful
PK