1

I have an application that will upload files from my client to a web server using HttpWebRequest (with the function suggested here: Upload files with HTTPWebrequest (multipart/form-data))

My problem is that when the file (about 10 mb in size) is being posted the whole application freezes (e.g. "application is not responding" when I try to move the window).

Do I need to put the uploading in a separate thread, or is there any other simple way solve this?

Community
  • 1
  • 1
hbruce
  • 934
  • 4
  • 11
  • 21

2 Answers2

2

Have a look at the BackgroundWorker class. Your UI will freeze while an operation is ongoing unless you run it in a separate thread.

Using the BackgroundWorker you can execute your code in the DoWork event and the UI will remain responsive.

djdd87
  • 67,346
  • 27
  • 156
  • 195
1

Multithreaded programming is the way to go in this case.

You can create a delegate for a function that will upload the file and use BeginInvoke to execute the function in a seperate thread.

Or you could simply create a new thread by using the Thread class and the build-in .net ThreadPool.