multithreading

Multi-Threading Question - adding an Element to a static List

Okay, newbie multi-threading question: I have a Singleton class. The class has a Static List and essentially works like this: class MyClass { private static MyClass _instance; private static List<string> _list; private static bool IsRecording; public static void StartRecording() { _list = new List<string>(); ...

Safe to get Count value from generic collection without locking the collection?

I have two threads, a producer thread that places objects into a generic List collection and a consumer thread that pulls those objects out of the same generic List. I've got the reads and writes to the collection properly synchronized using the lock keyword, and everything is working fine. What I want to know is if it is ok to access ...

Visual Studio Debug Mode - Peculiar Behaviour

In visual studio 2008 while in the debug mode when we initiate a thread and put break points inside the thread function. Visual Studio doesn't debug giving explanation that i don't have the code. Why does this happens. How to do it ...

Cross thread reading of a variable

In c#, is there a way of updating a variable (without using lock) where multiple threads can read the value, but the thread that updates the variable is not considered important. What I mean is, the value being updated isnt that important, so if a thread updates that value but the other threads don't get that updated value a few minutes...

Timers in .net - which to use when?

There are three Timer classes in .net (Timers.Timer, Threading.Timer and Windows.Forms.Timer). Which should be used when? and What are performance implication of using them? ...

Handling KeyboardInterrupt in a KDE Python application?

Hi, I'm working on a PyKDE4/PyQt4 application, Autokey, and I noticed that when I send the program a CTRL+C, the keyboard interrupt is not processed until I interact with the application, by ie. clicking on a menu item or changing a checkbox. lfaraone@stone:~$ /usr/bin/autokey ^C^C^C Traceback (most recent call last): File "/usr/lib...

CEvent-like behaviour with Boost.Thread

Problem in words: For my application, I have a class that reads from a serial port. It uses Windows primitives for COM port handling and had a thread for asynchronous reading. I'm trying to convert this away from Windows primitives using Boost libraries such as Boost.Asio and Boost.Thread. In the Windows port, my IO thread had severa...

Can I safely rely on IsBackground in Threads when the application terminates?

I'm running some background threads in the GUI. Currently I'm implementing a personal Thread cancellation code but there is IsBackground property in threads and according MSDN they'll cancel themselves. I know that it's going to Thread.Abort() which is nasty but there is nothing going in this background threads that I need to keep a pro...

Empty Worker Threads, What are they?

While debugging a .NET Framework 3.5, WinForms application I spotted some "Worker Thread"s without a name. I know when you open an application you've got a one worker thread by default. However in the middle of debugging when I pause the debugger and take a look at the "Threads" window I see about 5+ similar threads (priority=normal)....

Can a C function be used as a selector in Cocoa?

I want to start a new thread using a C function, not an objective-C method. I tried [NSThread detachNewThreadSelector: @selector(func) toTarget: nil withObject: id(data)]; where I have void func(void *data) { // ... } and data is a void *, but I get a runtime crash in objc_msgSend, called from -[NSThread initWithTarget:selector...

Monitor vs WaitHandle based thread sync

Hi I was under the impression, after reading this article http://www.yoda.arachsys.com/csharp/threads/ that it is better to use Monitor/Lock for thread synchronisation as it does not use native resources Specific quote (from page 5 of the article): Monitor.Wait/Pulse isn't the only way of waiting for something to happen in one thre...

How to implement a recursive MRSW lock?

I need a fully-recursive multiple-reader/single-writer lock (shared mutex) for my project - I don't agree with the notion that if you have complete const-correctness you shouldn't need them (there was some discussion about that on the boost mailing list), in my case the lock should protect a completely transparent cache which would be mu...

How to disable iphone UI?

I start doing some things on multiple threads and I want to disable the UI while the new thread is working so that the user doesn't accidentally launch a duplicate. Is there a good way to do this? ...

Common multithreading mistakes beginners make on iPhone...

I just introduced multithreading into my app JUST to get a silly UIActivityIndicatorView to work. Well, the activity indicator works, alright -- but now my app crashes sometimes, and sometimes it doesn't -- under otherwise controlled conditions... I need to figure this out but don't know where to start looking... So, what are some commo...

Custom System.Diagnostics.TraceListener output to RichTextBox hangs

I've a RichTextBox which I use as output from a custom TraceListener shown below: The trouble is this seems to deadlock hard if anyone is writing debug/trace info from other threads while a GUI dialog also is trying to write debug/trace info. Anyone care to point at some obvious errors here ? : class MyTraceListener : TraceListener { ...

how programmatically count context switches?

Under windows, is there anyway to programmatically count context switches of the same process? the best thing is a callback that gets called whenever a thread is switched. ...

C# Multithreading: Overhead of micro Thread sleeps

Hi, I have an application that grabs a snapshot of another desktop. This process is placed and run asynchronously in a separate backgroundworker thread. Tiny mockup of the DoWork event is: private void GrabImage_DoWork(object sender, DoWorkEventArgs e) { /*Grab the image..*/ System.Threading.Thread.Sleep(10) } Currently there was pl...

Is Java Regex Thread Safe?

I have a function that uses Pattern.compile and a Matcher to search a list of strings for a pattern. This function is used in multiple threads. Each thread will have a unique pattern passed to the Pattern.compile when the thread is created. The number of threads and patterns are dynamic, meaning that I can add more patterns and thread...

How to share data between different threads In C# using AOP?

How to share data between different threads In C# without using the static variables? Can we create a such machanism using attribute? Will Aspect oriented programming help in such cases? To acheive this all the different threads should work on single object? ...

Hi all,How to use TIMERS in vc++? I want to run different functions or code after a definite time interval(say 10 ms) without using Sleep().Please help

Hi all i want to execute code similar to a Interrupt service routine after a timer expires(say print hello after every 10ms) and this is a supplementary activity so it has to be using a timer .So how do i implement timers in vc++ ...