Avatar of jdcoburn
jdcoburn

asked on 

protection of common resource from multiple theads

hi -- I'm using .Net 4.0 and VS2010 with C#. I have a primary thread (the UI thread) which has in it a driver-  handler to a USB based external device. I access the device so that only one post is outstanding at a time, which works fine by itself. I also have a background thread (a monitor thread) that needs to access the same external resource on a periodic basis. Where i run into trouble is with one thread posted and another overlaps the outstanding message.

I've played with various interlocking schemes, including using WaitOne, but i still have problems. So, I'm hoping you can suggest how this should work. I have a feeling i've been placing the WaitOne in the wrong place (I put it in the primary thread at the top of the driver call).  I think it should go in the background thread with access controlled by set and reset in the primary code. is this correct? if so, how do i stop the foreground thread from accessing the resource while the background thread is using it? Do i use two WaitOne's with two different interlocks?

thanks,
.NET ProgrammingC#

Avatar of undefined
Last Comment
Mike Tomlinson
ASKER CERTIFIED SOLUTION
Avatar of HooKooDooKu
HooKooDooKu

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of jdcoburn
jdcoburn

ASKER

I can't get to either link.
?...they're working fine for me.  Are you behind a corporate firewall with some kind of filtering?

Here's another one:
http://www.dotnetperls.com/lock
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo