AFC08 Posted February 24, 2009 Posted February 24, 2009 The application is basically this: I have three buttons in my form, lets say Btn1, Btn2 and Btn3. Everytime i click btn1 i start ThreadA. ThreadA reads certain msg from my DB and displays them in the form textbox. If i click on Btn2, ThreadA is stopped and THreadB starts, which shows different messages. This way, if i click on Btn1 again I start the process where i got interrupted. When I pres Btn2 and ThreadB has started i have two options: If i click on Btn3 then in relation to the msg i have currently displayed I will display another one, however if i keep it pressed for more than 2 seconds i will be going thru a loop of messages and then go back to the point where the process from Btn2 was interrupted, and if this time goes more than 2 min than everythings gets stopped. I have tried to use the timer so i can imitate the idea of holding a button (not just cliking it), but it doesnt work well. I made the timer interval = 2000 (for 2 sec), but it keeps calling the thread every 2 sec. That is not what i want. I want to have a timer in the background which count the seconds that are passing when the button_mousedown function is called. Can anyone help please?? Quote
stumper66 Posted February 25, 2009 Posted February 25, 2009 Perhaps you'd want to use System.Diagnostics.StopWatch ? http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx Quote
AFC08 Posted February 25, 2009 Author Posted February 25, 2009 I looked at the Stopwatch function but the problem i was facing was that once i press down on the button i start the watch, but i need to have a loop while the time is being counted (so i want a real time count of the seconds, once it hits the value i want i will call my thread but i dont want to stop the watch because if the time goes more than 2 min i need to stop everything). How can i do this with Stopwatch?? I tried, but it wasnt working.. Any help will be great. Thank you all Quote
Administrators PlausiblyDamp Posted February 28, 2009 Administrators Posted February 28, 2009 Could you not just use 2 stop watches - one as alreday suggested and one that waits for the two minutes? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.