Click here to Skip to main content
15,868,102 members
Please Sign up or sign in to vote.
5.00/5 (4 votes)
See more:
C# Question.

Hi,

While the program is performing a task code, for example, looping or reading a text file a mysql database, how can one display a running counter on the same form the task was originated or a separate form. (Thus at same time do a task and also display/update a label with counter value).

In Form 1 the following:
- Setup to text file and mysql connection.
- Read line for line by using a while statement.
- After line was read, other codeinterpret the line and do somethigh and then by using SQL insert statement add to Mysql database.

Question.
While looping want to display to the user that somethigh is happening. Perhaps display counter for every line read and display as labelon same form1 or it can be a another form just displaying the counter value. I tried to use thread, but does not want to work. There should be a simple solution ?

Can anyone give a suggestion ?
Thank you
Posted
Comments
Dalek Dave 7-Jan-11 3:35am    
Good Question, and well laid out.
thatraja 8-Jan-11 2:26am    
You have asked the question very well. 5!

See this link:

See Here[^]
 
Share this answer
 
v3
Comments
Dalek Dave 7-Jan-11 3:36am    
Good Link.
You can make use of ProgressBar and its ReportProgress event to do this.
 
Share this answer
 
Comments
Dalek Dave 7-Jan-11 3:36am    
Fair enough answer.
thatraja 8-Jan-11 2:25am    
Good answer

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