Click here to Skip to main content
16,016,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a processing image which i want to show while a time taking function is executed

Following is my code
C#
pictureBox1.Visible=true;
send();//time taking function
pictureBox1.Visible=false;
MessageBox.show("success");

But i cant see the image and success message comes before the end of execution of send()

Please help....
Posted
Updated 26-May-13 23:00pm
v2
Comments
Richard MacCutchan 27-May-13 4:10am    
You need to wait for the processing of the send() function to complete. Either by a timed wait, or receiving a notification from the receiver.
Himu from Orissa 27-May-13 4:18am    
Cant get you can you please show me some link or example

1 solution

Why not move the processing task into a BackgroundWorker[^] thread?
You create the thread, show the image, and start the worker.
In the worker completed event, you hide the image.
That way your UI remains responsive, and the task is handled in the background.

The link includes an example.
 
Share this answer
 
Comments
Himu from Orissa 27-May-13 4:48am    
Actually the send() returns something, can i receive the output using BackgroundWorker
OriginalGriff 27-May-13 5:19am    
Yes.
Set the DoWorkEventArgs.Result property in your DoWork handler, and retrieve it from the RunWorkerCompletedEventArgs.Result in the completed event handler. It's an object property, so you can return any type of value you want and cast it back when you want to use it in the RunWorkerCompleted handler.
Himu from Orissa 28-May-13 5:46am    
thanx
OriginalGriff 28-May-13 5:50am    
You're welcome!
Himu from Orissa 28-May-13 6:01am    
Please sir have a look at my new problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900