I'm looking for a design pattern to switch from using a ManualResetEvent to using Thread methods like Thread.Join. Right now I'm making an async call and then using a ManualResetEvent to wait till the async call finishes before continuing on the thread that made the call.
I'd be glad for any implementation that would produce more stable...
Hello,
I wrote my code using this article at msdn as a primary helper
My code:
private ManualResetEvent _AllDone = new ManualResetEvent(false);
internal void Initialize(int port,string IP)
{
IPEndPoint _Point = new IPEndPoint(IPAddress.Parse(IP), port);
Socket _Accpt = new Socket(AddressFamily.InterNetwork...
I implemented the following background processing thread, where Jobs is a Queue<T>:
static void WorkThread()
{
while (working)
{
var job;
lock (Jobs)
{
if (Jobs.Count > 0)
job = Jobs.Dequeue();
}
if (job == null)
{
Thread.Sleep(1);
...
I'm a little confused over a ManualResetEvent that I'm using which doesn't appear to be unblocking. Anyone know why this might be the case?
The scenario I've got is something along these lines. The real situation is quite complicated and I've not managed to isolate a section of code that's reasonable to post to reproduce the issue.
EDI...
This is a followup to
WinForms RichTextBox: how to perform a formatting on TextChanged?
I have a Winforms app with a RichTextBox, the app auto-highlights the content of said box. Because the formatting can take a long time for a large document, 10 seconds or more, I've set up a BackgroundWorker to do the re-formatting of a RichTextBox. ...
I am not sure which strategy to adopt...I am focusing on my operation getting completed, but I'd also like to keep performance issues to a min too...there is a method called Execute() which has to wait (run synchronously) until an operation completes. This operation happens on another thread. There are 2 ways to implement the same thing....
I feel like I should know the answer to this, but I'm going to ask anyway just in case I'm making a potentially catastrophic mistake.
The following code executes as expected with no errors/exceptions:
static void Main(string[] args)
{
ManualResetEvent flag = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(s =>
{
...
I'm creating a server-type application at the moment which will do the usual listening for connections from external clients and, when they connect, handle requests, etc.
At the moment, my implementation creates a pair of threads every time a client connects. One thread simply reads requests from the socket and adds them to a queue, an...
Consider a Console application that starts up some services in a separate thread. All it needs to do is wait for the user to press Ctrl+C to shut it down.
Which of the following is the better way to do this?
static ManualResetEvent _quitEvent = new ManualResetEvent(false);
static void Main() {
Console.CancelKeyPress += (sender,...
Little intro:
In complex multithreaded aplication (enterprise service bus ESB), I need to use Thread.Abort, because this ESB accepts user written modules which communicates with hardware security modules. So if this module gets deadlocked or hardware stops responding - i need to just unload this module and rest of this server aplicatio...
Hi,
I have written what I hope is a lightweight alternative to using the ManualResetEvent and AutoResetEvent classes in C#/.NET. The reasoning behind this was to have Event like functionality without the weight of using a kernel locking object.
Although the code seems to work well in both testing and production, getting this kind of th...
I have the following code for a sample console app to simulate a Windows Service.
class Program
{
private Timer timer;
private object syncRoot = new object();
private bool stopSignalled = false;
private ManualResetEventSlim mre = new ManualResetEventSlim(false);
static void Main(string[] args)
{
Program p...