multithreading

Threading newbie with issue with runaway threads...

Ok, to you understand I will explain the problem: I am using a library called ClanLIB (not my choice), that library, SEEMLY (I am not certain, even reading the sourcE), creates a thread that handles sound. This thread, when the buffer is empty, tries to fetch more data, usually this cause a underrun when the data generating library is t...

Retrieving the number of physical core processors

I know I can use System.Environment.ProcessorCount to return the number of "processors" in a machine. What I am trying to do is find out if there is a way to determine the number of cores in the processor, not including hyperthreading as a "core". For example, on a dual core hyperthreading processor, System.Environment.ProcessorCount wil...

How to Create/Run AsyncTask in Service without runOnUiThread()

I have a Service that creates AsyncTasks for downloading files. In activities, we create Runnables or Threads that we pass to Activity.runOnUiThread(). I can't access that method from a service, so how do I use AsyncTask correctly, (do heavy work without blocking the UI Thread)? ...

How to ensure background thread ends when application ends?

I have an asp.net application with a background thread. The thread starts when the application starts and it is gracefully stopped when the application ends. I am running the website on a shared host. Unfortunately sometimes the application does not trigger the Application_End event when it ends. I would think that the threads would be k...

PostThreadMessage sets GetLastError to 1444

In PostThreadMessage my thread ID is correct, but I am getting the error 1444 ("Invalid thread identifier. "). Anyone know how to fix it? ...

Bulk Insert to Sqlite3 causing Db Error: Library routine called out of sequence

I need to load some configuration data after app updates for my iphone app. I bundle in a file with a bunch of SQL statements (800+) to run on first launch. It looks like I may be painted in a corner now. If I run it on the main thread at startup, it take so long to run that the app crashes due to the startup taking too long. If I ru...

Named pipes: Many clients. How to be prudent with thread creation? Thread Pool?

Situation: I'm am using named pipes on Windows for IPC, using C++. The server creates a named pipe instance via CreateNamedPipe, and waits for clients to connect via ConnectNamedPipe. Everytime a client calls CreateFile to access the named pipe, the server creates a thread using CreateThread to service that client. After that, the ser...

Unordered threads problem

I had asked question about lock in here and people responded there is no problem in my lock implementation. But i catched problem. Here is same lock implementation and i am getting weird result. I expect to see numbers starts from 1 but it starts from 5.Example is at below. class Program { static object locker = new object(); st...

Strange behavior of ThreadStatic

I have the code: internal static class IdCounter { [ThreadStatic] private static int _id = 0; static IdCounter() { } public static int Id { get { lock(typeof(IdCounter)) { return _id++; } } } } public abstract class Request { ...

glGenTextures returns zero in background thread

I need to load textures in background thread in OpenGL ES. But glGenTextures always returns zero when called in background thread. -(void) someMethodInMainThread { [self performSelectorInBackground:@selector(load) withObject:nil]; } -(void) load { GLuint textureID = 0; glGenTextures(1, &textureID); } textureID is zer...

Rhinomocks with .net 4 threading

So I have a little app which will process a load of files and I'm trying to write tests for the class which will handle looping through the files and firing them to various places. This was an obvious place to try out the new parallel library stuff. Heres a simplified version of the code I'm testing: public void ProcessSomeFiles(IEnumer...

Converting graph traversal to multiprocessing in Python

I've been working on a graph traversal algorithm over a simple network and I'd like to run it using multiprocessing since it it going to require a lot of I/O bounded calls when I scale it over the full network. The simple version runs pretty fast: already_seen = {} already_seen_get = already_seen.get GH_add_node = GH.add_node GH_add_e...

Thread synchronization/scheduling in perl

I have a perl object with a few functions in it. Each functions is called once from the main program. I would like to run some of the functions in parallel to save time. I can't run all of them together since some functions depend on the results of previous functions. I thought of something like this: For each function keep a flag tha...

Ordered execute threads

Hello everybody I have an console application which interact another user interface. Interface sends commands and my application should to process them. It is important to keep listening my console application while processing and execute commands in ordered. So i listen interface on main thread and execute commands in another thread. ...

How can I update a winform asynchronously?

I've got a winform, and a bluetooth connection with a lego nxt brick. Now I want to update the form every second to read sensors or the battery level. But if I start a new thread for that, there i a invalid thread operation exception when the thread wants to set the label text. Can anyone help me? ...

Cross-thread operation exception when worker thread adds to BindingList

I have a worker thread that needs to add items to a BindingList. However, the BindingList is databound to a DataGridView. So, when I try to add to the list, I get an InvalidOperationException (Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.) Normally for this exception you would ...

Debugging multithreaded code with gdb but no access to private variables?

Hey guys. My program uses OpenMP at a few parts to do multithreading. It works for the most part, but occasionally stalls and just sits there. So I run it in the debugger, and I find the area it is stalling at. Then I try to examine the current variables, and I get this: 169 if(0<=myPtr[3] && myPtr[3]<=1){//Reassign the velocities....

LINQ-SQL & ADO.NET - How to make a bulk transaction entirely asynchronous?

Hi Guys, So i'm dealing with an ASP.NET 4.0 Web Forms Application in which the DAL is built with a combination of LINQ-SQL and classic ADO.NET (for auditing transactions, and bulk updates). I have an admin page on the site which performs an update on a bunch of records (could be thousands), and not to mention there is T-SQL triggers in...

Does a static method share its local variables & what happens during concurrent usage from different threads?

C# Question - I'm trying to determine whether it is OK to use a static method where, within the method it does have some local variables it uses. Are the local variables "shared" across usages of the method? What happens for example if the static method is being called/used at the same time from different threads? Does one thread bloc...

PostMessage returns "invalid window handle" in thread

Background: I am using OmniThreadLibrary to load batch mode ADO stored procedures in the background. I am doing some slightly dodgy stuff by swapping the connection after opening the SP but that seems to be quite reliable. I'm using PostMessage to send messages back to the calling form and that works in my test applications. Primoz' comm...