Open jascam opened 6 years ago
Hello emari2
Thank you for using our code sample request service.
I'd like to confirm with you my understanding of the sample request:
There will be two or threads (depending on what timer would you like to you. Windows.Forms.Timer? or Threading.Timer?) involved in this code sample. If you use Threading.Timer, it is three threads:
Thread 1: the timer thread for Threading.Timer Thread 2: the thread that "does the job" for the passed string Thread 3: the UI thread
The timer thread (thread 1) checks a tcp port every 100ms. When the timer thread finds the wanted string, it wakes the thread 2 to do the job upon the string. When thread 2 finishes the job, it asks the UI thread (thread 3) to update the UI, and then goes asleep, until next time, thread 1 finds another string, and wakes it up to do the job.
Is my understanding correct? Please let me know if I misunderstood your needs.
This looks a request of a multi-threading code sample. The wake and sleep logic of thread 2 can be implmeneted using a ManulResetEvent (http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspx).
Let's see how many people will vote for it.
Thanks All-In-One Code Framework http://1code.codeplex.com
This comment was posted by Jialiang on 1/10/2011
Thanks a lot Jialiang. You understood perfectly well my request. I have been programing since 1981 and will all the visual basic updates but never took the threading line of programming and now for my simulations (I get my retirement the next 28th- 65 and still learning) it is a a departure issue that I want to learn. I read a lot about threading but I gave up at this one as I do not know how to imprement: first the first thread, second the passing parameters etc. even when yerterday I have been studing a bit about delegates. But any help will be appreciated and I am quite sure it would be good for the general programming comunity. Again, many thanks.
This comment was posted by emari2 on 1/10/2011
This comment was posted by on 1/20/2011
This comment was posted by on 8/28/2011
This comment was posted by on 2/15/2012
This comment was posted by on 2/21/2013
Need a Thread that checks a tcp port every 100 miliseconds looking for a certain string but If it finds the string during this time(maybe in the milisecond 12) it starts a second thread and pass the string to it to do the job. Once the job is finished this thread pass the data to form1 thread to display the calculation in a control and has to be stopped to start again when started by the first thread. Note.- I do the job in only one thread, I mean only in a single form with several subs and functions inside a timer with an interval of 100 miliseconds but I cannot implement it with threads even reading the existing examples. Thanks I am talking about doing it in Visual Basic(8-10) Net
Migrated CodePlex Work Item Details
CodePlex Work Item ID: '8107' Vote count: '4'