Advertisement

06.03.2008 at 07:01AM PDT, ID: 23453143
[x]
Attachment Details

VB.NET: How can I have a Thread suspend while waiting for an event?

Asked by m8online in Visual Studio .NET 2003, .NET, Microsoft Visual Basic.Net

Tags: VB.NET

Hello,

I am writing an interface to a peripheral.

When getting data from the peripheral I send data through USB. the device then sends a reply containing the requested data.

As the device can also send data without me requesting it I set up a seperate thread (hi prio) to receive messages.

The transaction then goes as follow:
The send function sends a message to the peripheral, then loops waiting until the arrival of a reply is signalled. This is done by setting / reseting a boolean.
the receiver thread sets the boolean to signal that a specific reply came in.

Basically I have 2 problems.
1:  
The wait loop in the send thread is now implemented with a while / Sleep(1) combination.
Sleep(1) often takes much much more than 1 ms (10 - 80ms) , thus killing the transaction performance.
Instead I would need some semaphore like solution that immediately wakes up the thread when the requested data has arrived and does not first serve a 100 other threads in between like Sleep() seems to do. How should I implement this? Can this be done using the Semaphore class?

2:
Both the receiver and the sender thread output debug data into a textbox. How should I prevent them from accessing it at the same time?
Currently I use a shared boolean/Sleep(1) construction, but it slows down things a lot
Start Free Trial
 
Keywords: VB.NET: How can I have a Thread s…
 
Loading Advertisement...
 
[+][-]06.03.2008 at 08:00AM PDT, ID: 21701046

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 08:33AM PDT, ID: 21701438

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 08:46AM PDT, ID: 21701585

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 08:50AM PDT, ID: 21701633

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 10:02AM PDT, ID: 21702329

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 10:16AM PDT, ID: 21702477

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 10:32AM PDT, ID: 21702608

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 10:49AM PDT, ID: 21702727

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 11:20AM PDT, ID: 21702973

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 12:35PM PDT, ID: 21703749

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 10:06PM PDT, ID: 21707095

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 09:07AM PDT, ID: 21711474

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 10:58AM PDT, ID: 21712404

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 11:16AM PDT, ID: 21712549

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 11:24AM PDT, ID: 21712633

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 12:56PM PDT, ID: 21713560

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 02:09PM PDT, ID: 21714176

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 01:28PM PDT, ID: 21723611

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 01:43PM PDT, ID: 21723768

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio .NET 2003, .NET, Microsoft Visual Basic.Net
Tags: VB.NET
Sign Up Now!
Solution Provided By: Idle_Mind
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628