multithreading

.NET Backgroundworker Object's Thread Priority

I am trying to use the .NET Backgroundworker Object in an application I am developing. All the material on the internet say that this object runs in the "background" but nowhere have I been able to confirm that this background thread indeed runs in a "low priority" mode. This question arises because in Windows (I assume) a background ta...

Is this code threadsafe?

I'm writing some code where the UI thread need to communicate with the background thread doing network communication. The code works, but would it be considered thread safe? I would feel a lot better if someone experienced could lead me on to the right path on this... static Mutex^ mut_currentPage = gcnew Mutex; static array<unsigned c...

rdts to mark time deadlines

I have a code that "sounds" like this: thread 1 now = rdtsc(); for_each_member_in_a_list { if ( member_in_list.deadline() <= now ) { do_something; } } thread 2 now = rdtsc(); for_each_member_in_a_list { member_in_list.updatedealine( foo(now, ...) ); } now while this was working good in the past now with a SMP system...

Python, SQLite and threading

I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP. So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database. Then in the...

WPF: Building a Queue in a Thread with Timers

With reference to the Software Project I am currently working on. I have the below methods that basically move a canvas with a Timer: DispatcherTimer dt = new DispatcherTimer(); //global public void Ahead(int pix) { var movx = 0; var movy = 0; dt.Interval = TimeSpan.FromMilliseconds(5); ...

Console menu updating OpenGL window

I am making an application that does some custom image processing. The program will be driven by a simple menu in the console. The user will input the filename of an image, and that image will be displayed using openGL in a window. When the user selects some processing to be done to the image, the processing is done, and the openGL windo...

.NET remoting threading model

Hi, I would like to know how threads are handled on the server side using MarshalByRef objects. Given my remoted MarshalByRef class: public class MyRemotedClass : MarshalByRef { public int MyInt; public string MyString; } Client code (single threaded): MyRemotedClass m = GetSomehowMyRemotedClass(); m.MyInt = 5; // Write operat...

python console intrupt? and cross platform threads

I want my app to loop in python but have a way to quit. Is there a way to get input from the console, scan it for letter q and quick when my app is ready to quit? in C i would just create a pthread that waits for cin, scans, locks a global quit var, change, unlock and exit the thread allowing my app to quit when its done dumping a file o...

Impossible (how I hate to use this word) cross threading error?

Can anybody please explain how this could possibly happen? I am completely aware of programming with thread safety in mind and as you can see I am catering for UI updates via a form InvokeRequired check here, everything has been working fine and no changes to break this that I am aware, and now suddenly just as I'm programming other par...

How to debug deadlock with python?

I am developing a multi-threading application, which is deadlocking. I am using Visual C++ Express 2008 to trace the program. Once the deadlock occurs, I just pause the program and trace. I found that when deadlock occurs, there will be two threads called python from my C++ extension. All of them use Queue in python code, so I guess ...

input and thread problem, python

I am doing something like this in python class MyThread ( threading.Thread ): def run (s): try: s.wantQuit = 0 while(not s.wantQuit): button = raw_input() if button == "q": s.wantQuit=1 except KeyboardInterrupt: s.wantQuit = 1 my...

Identifying the client during a .NET remoting invocation

Hi, Given this MarshalByRef class: public class MyRemotedClass : MarshalByRef { public void DoThis() { ... } public void DoThat() { ... } } Client side code: MyRemotedClass m = GetSomehowMyRemotedClass(); m.DoThis(); m.DoThat(); I can have several clients doing the same thing at a the same time. I would like ...

How to output data form a thread to another thread without locking?

I'm developing a DirectShow application. I encounter a deadlock problem, the problem seems caused by acquire lock in a callback function called from a thread. This is the quest I asked in MSDN forum: http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/f9430f17-6274-45fc-abd1-11ef14ef4c6a Now I have to avoi...

C# Function Awareness?

In a multi-thread app. is there a way to programatically have thread-B check what function thead-A is currently in? ...

Creating a blocking Queue<T> in .NET?

I have a scenario where I have multiple threads adding to a queue and multiple threads reading from the same queue. If the queue reaches a specific size all threads that are filling the queue will be blocked on add until an item is removed from the queue. The solution below is what I am using right now and my question is: How can this b...

Trap exception from background thread

Hello, concurrent colleagues. I need to be able to trap an exception that might be thrown from a background thread. Let the code speak for itself (it is a bad code) public delegate bool CheckForUpdatesHandler(Uri uri); public class UpdatesChecker { public event AsyncCompletedEventHandler CheckForUpdatesAsyncCompleted; ...

Is EndInvoke() optional, sort-of optional, or definitely not optional?

I've read conflicting opinions as to whether every BeginInvoke() has to be matched by an EndInvoke(). Are there any leaks or other problems associated with NOT calling EndInvoke()? ...

WPF: How to handle errors with a BackgroundWorker

I am a bit of a newbie when it comes to windows client programming. I have a background worker that has a DoWork event and a RunCompleted event wired up. If an exception gets thrown in DoWork, I want to make changes to my UI, however, I cant because it is in a different thread. I can communicate the error to RunCompleted, but that doesn'...

What's the difference between QueueUserWorkItem() and BeginInvoke(), for performing an asynchronous activity with no return types needed

Following on from my BeginInvoke()/EndInvoke() question, are there major differences in performance/anything else between Delegate.BeginInvoke() and using QueueUserWorkItem() to invoke a delegate asynchronously? ...

Beginners threading in C#

Can you recommend a good series of articles or preferably a book on how to get started with threading in general and in C# in particular? I am primarily looking for the use of threads in console applications and in ASP.Net apps. I understand only the very basics of threads and know that "here be dragons", so want to get a good grounding...