tags:

views:

124

answers:

1

Hello,

I've got a C# winapp that communicates with a java app to retrieve data over tcp. Now I want to add a progressbar for the waiting and showing that the download of the data is busy. Because at this moment the winapp freezes until it has all the data from the java.

Now I was wondering how I could program it. Because I assume that the java should return something from time to time to set the progressbar in the c#.

I guess I need to do it with threads, but I'm not really sure on how to do it.

If somebody has some other ideas or examples, that would be great.

Thanks in advanced

+2  A: 

BackgroundWorker is almost certainly what you want on the WinApp side. The ReportProgress method and ProgressChanged event are used to handle updating the progress bar.

However, you'll need to work out how to decide how much progress has actually been completed. If you give us more idea what the Java app's doing, we could help a bit more.

Jon Skeet
The java app was needed because I got a java api for connecting to a server and fetch data from it. This send back in string format and ; seperated. Maybe the java can send something to notify the c# thru the tcp?
Gerbrand
I will have a look at the backgroundworker
Gerbrand
My point is that you'll need some idea of how close the Java app is to finishing if you're going to give a meaningful idea of progress.
Jon Skeet
Hmm that can be a problem. since the java is downloading data from a server and I don't know how many data I will receive. But okay I will see what I can do on knowing this.
Gerbrand