G
George Chatzigeorgiou
Hi all.
I'm having this problem:
My app , reads an xml file through Http , parses it for file version
differences with the local files, and starts downloading newer files.
This propably takes some time, so I want to show some progress
information to the user before he starts pressing every available button
on the device. I wish, that is. Because trying every available
configuration and combination but to no avail. Let me explain.
Option 1: Create an HttpWebRequest, an HttpWebResponse, and start
reading blocks of data. After every block , update the progress bar.
Result: Not only the progress bar doesn't update (repaint, refresh is
somewhat chocked by the Read method ), but after the first download
finished, the main thread exits. I take care to close everything after
the end of the download, but the problem persists.
Option 2: Use asynchronous transfer, and Control.Invoke for updates.
(same as the MSDN sample).
Result: Progress bar updates, but after the first operation is
completeted, guess what: main thread dies. Moreover there is no way to
control the operation (I need to replace the old file, but I wouldn't
know when the async. operation has finished....so option 3).
Option 3: Use asynchronous operations, and ManualResetEvent singaling to
control the operation.
Result: If I try to Invoke, everything dies. If I don't Invoke (for
progress bar update), after the first operation has finished, the main
thread dies.
It seems, that somehow, someone wants to delete a thread , and because
no other than the main thread is available, the app exits. I tries a
really big delay (like Thread.Sleep(1000000)) to give time to the next
webResponse to fire, and it worked until the next progress bar update
crashed everything again.
I'm sure I'm doing something terribly wrong, an RTFM somewhere in the
last page or whatever.
Any ideas?
Thanks in advance.
I'm having this problem:
My app , reads an xml file through Http , parses it for file version
differences with the local files, and starts downloading newer files.
This propably takes some time, so I want to show some progress
information to the user before he starts pressing every available button
on the device. I wish, that is. Because trying every available
configuration and combination but to no avail. Let me explain.
Option 1: Create an HttpWebRequest, an HttpWebResponse, and start
reading blocks of data. After every block , update the progress bar.
Result: Not only the progress bar doesn't update (repaint, refresh is
somewhat chocked by the Read method ), but after the first download
finished, the main thread exits. I take care to close everything after
the end of the download, but the problem persists.
Option 2: Use asynchronous transfer, and Control.Invoke for updates.
(same as the MSDN sample).
Result: Progress bar updates, but after the first operation is
completeted, guess what: main thread dies. Moreover there is no way to
control the operation (I need to replace the old file, but I wouldn't
know when the async. operation has finished....so option 3).
Option 3: Use asynchronous operations, and ManualResetEvent singaling to
control the operation.
Result: If I try to Invoke, everything dies. If I don't Invoke (for
progress bar update), after the first operation has finished, the main
thread dies.
It seems, that somehow, someone wants to delete a thread , and because
no other than the main thread is available, the app exits. I tries a
really big delay (like Thread.Sleep(1000000)) to give time to the next
webResponse to fire, and it worked until the next progress bar update
crashed everything again.
I'm sure I'm doing something terribly wrong, an RTFM somewhere in the
last page or whatever.
Any ideas?
Thanks in advance.