Help required in Threading..
-
hello, I am using Threads in my app that runs a process of writing data on Pole(Customer)-Display Hardware Device. Now this thread calls every single second. And what is happening is that the 1st thread have'nt write its content completely and 2nd thread called and it disturbs the 1st one as well. I have'nt played much with Threads, Can i make thread to wait in a way that If a thread is called it should check 1st that if any other thread already running the same method, it should wait for that thread to end. Thanks in Advance, Asfand
-
hello, I am using Threads in my app that runs a process of writing data on Pole(Customer)-Display Hardware Device. Now this thread calls every single second. And what is happening is that the 1st thread have'nt write its content completely and 2nd thread called and it disturbs the 1st one as well. I have'nt played much with Threads, Can i make thread to wait in a way that If a thread is called it should check 1st that if any other thread already running the same method, it should wait for that thread to end. Thanks in Advance, Asfand
-
hello, I am using Threads in my app that runs a process of writing data on Pole(Customer)-Display Hardware Device. Now this thread calls every single second. And what is happening is that the 1st thread have'nt write its content completely and 2nd thread called and it disturbs the 1st one as well. I have'nt played much with Threads, Can i make thread to wait in a way that If a thread is called it should check 1st that if any other thread already running the same method, it should wait for that thread to end. Thanks in Advance, Asfand
yes you can configure the propertiese of your thread to wait for complete execute befor newest thread be running. the method is join() (ThreadName.join()). i hope this method help you to solve your problem.
nobody help you... you have to help you yourself and this is success way.
-
hello, I am using Threads in my app that runs a process of writing data on Pole(Customer)-Display Hardware Device. Now this thread calls every single second. And what is happening is that the 1st thread have'nt write its content completely and 2nd thread called and it disturbs the 1st one as well. I have'nt played much with Threads, Can i make thread to wait in a way that If a thread is called it should check 1st that if any other thread already running the same method, it should wait for that thread to end. Thanks in Advance, Asfand
If you are using a timer to initiate the threads then in the tick event you need to disable the timer till it is completed processing.
Never underestimate the power of human stupidity RAH
-
hello, I am using Threads in my app that runs a process of writing data on Pole(Customer)-Display Hardware Device. Now this thread calls every single second. And what is happening is that the 1st thread have'nt write its content completely and 2nd thread called and it disturbs the 1st one as well. I have'nt played much with Threads, Can i make thread to wait in a way that If a thread is called it should check 1st that if any other thread already running the same method, it should wait for that thread to end. Thanks in Advance, Asfand
This might sound daft (it probably is :-D ) but if you cannot perform operation 2 until operation 1 has finished what on earth is the benefit of using threads?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.
-
yes you can configure the propertiese of your thread to wait for complete execute befor newest thread be running. the method is join() (ThreadName.join()). i hope this method help you to solve your problem.
nobody help you... you have to help you yourself and this is success way.
thnx alot, it worked :)
-
thnx alot, it worked :)
It seems to me that if the writing threa is busy, you swould be better advised to ignore the current write request, and just write when the thread isn't busy. Eventually, you're going to deadlock the machine because you're waiting for the thread to finish. You may even want to have the timer adjust its interval so that there's less of a chance of the thread being in a busy state.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
This might sound daft (it probably is :-D ) but if you cannot perform operation 2 until operation 1 has finished what on earth is the benefit of using threads?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.
You're absolutely right. Simply having two threads continuously waiting one on the other isn't necessarily better than having just one thread handle everything. However, assuming a multi-core processor is used, a ping-pong approach (two buffers, one filled by the producer, one emptied by the consumer, and switching places based on an overall clock) could double the throughput. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
You're absolutely right. Simply having two threads continuously waiting one on the other isn't necessarily better than having just one thread handle everything. However, assuming a multi-core processor is used, a ping-pong approach (two buffers, one filled by the producer, one emptied by the consumer, and switching places based on an overall clock) could double the throughput. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
Luc Pattyn wrote:
(two buffers, one filled by the producer, one emptied by the consumer, and switching places based on an overall clock) could double the throughput.
I thought something like that when I read the original question. There's probably a name for the technique, although I am not aware of it. Some form of Queue-like structure that the producers add their output to with a consumer that takes the head of the queue and displays it.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.
-
Luc Pattyn wrote:
(two buffers, one filled by the producer, one emptied by the consumer, and switching places based on an overall clock) could double the throughput.
I thought something like that when I read the original question. There's probably a name for the technique, although I am not aware of it. Some form of Queue-like structure that the producers add their output to with a consumer that takes the head of the queue and displays it.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.
-
Luc Pattyn wrote:
(two buffers, one filled by the producer, one emptied by the consumer, and switching places based on an overall clock) could double the throughput.
I thought something like that when I read the original question. There's probably a name for the technique, although I am not aware of it. Some form of Queue-like structure that the producers add their output to with a consumer that takes the head of the queue and displays it.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.
we've always referred to it as "ping-pong buffering" and that is also mentioned near the middle of this[^]. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).