multithreading

How to know that I have another thread running apart from the main thread?

Suppose I have a routine like this: private void button1_Click(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart(Some_Work)); t.Start(); } I need to put a condition so that, "If there is not already a thread running apart from the Main thread, start a new thread". But how to test for whether a thread is runn...

Is there a cross platform version of window vista's slim reader writer locks?

I'm totally blown away from the quality of windows SRW implementation. Its faster then critical sections and its just a few bytes memory overhead. Unfortunately it is only Windows Vista/Windows 7. As this is a pure user land implementation, does anybody know if there is a cross platform implementation for it? Has anybody reverse-engi...

How to Cancel a Thread?

In case of BackgroundWorker, a cancel can be reported by the e.Cancel - property of the DoWork - event handler. How can I achieve the same thing with a Thread object? ...

Is there a better way to block a C# timer when interacting with the user?

I am using a System.Windows.Forms.Timer component on an application's main form which checks every minute for updates on a database. However, there are a number of possible interactions with the user, such as modal dialogs being thrown for certain operations. In general, I don't want this timer to fire when the user is "busy" or while an...

PipedInputStream - How to avoid "java.io.IOException: Pipe broken"

I have two threads. One of them writes to PipedOutputStream, another one reads from corresponding PipedInputStream. Background is that one thread is downloading some data from remote server and multiplexes it to several other threads through piped streams. The problem is that sometimes (especially when downloading large (>50Mb) files)...

How can I implement a MultiThreaded Transaction in C#?

I want to run set of different commands on different tables in parallel and in a transactional way, how can I do that? More details: I want all the commands to be distributed over threads but in a single transaction, so if all the threads succeed I'll commit else rollback. ...

Writing to a server, reading from a cache.

I have a client WinForm that uses a web service to write to a server database. When it loads, it starts a thread that polls the server for new entries to the database. When found, the new entries are downloaded and stored in a cache (embedded database). The thread flow is as follows: while(continueSynchronizing) { foreach(Table t i...

Restrict certain URLs to a single thread

I have a nice little threading problem with a library I use to generate and serve dynamic graphs and charts in Zope. See this question for a description of my original problem. As the website is already in production, I don't have time to debug that library (I'm not an expert in either C nor threading), hence I'm looking for the quick f...

boost::asio multi-threading problem

Ive got a server that uses boost::asio which I wish to make multi-threaded. The server can be broken down into several "areas", with the sockets starting in a connect area, then once connected to a client being moved to a authentication area (i.e. login or register) before then moving between various other parts of the server depedning ...

How to code a responsive progress bar that uses callback functions?

I have this progress bar that uses callback functions from a third party driver, to display a traditional progress bar in a window called CFProgress. CFProgress *cFM=new CFProgress(); theApp.m_cFM = cFM; cFM->Create(CFProgress::IDD); cFM->ShowWindow(SW_SHOW); thirdpartydriver->set_OnProgress(ProgressFuncC, (void *) cFM); thirdpartydrive...

Is there a UNIX/pthreads equivalent to Windows manual reset events?

Briefly, a manual reset event is a synchronization construct which is either in the "signaled" or "nonsignaled" state. In the signaled state, any thread which calls a wait function on the event will not block and execution will continue unaffected. Any and all threads which calls a wait function on a nonsignaled object will block until...

How to catch connection timeout exceptions from XSD-generated typed DataSets?

This might be a bit complicated, but bear with me. I have a Windows Forms app. It uses strongly typed DataSets via the XSD designer. I am running data access queries via an asynchronous thread, performed like so: // Calling it in code on the main thread: LoadDataList_WorkerCaller dataDelegate = new LoadDataList_WorkerCaller(LoadDataL...

WPF Multithreading...

I am building a WPF application that calls web services and displays the data returned from the service after being broken down and analyzed by my application. The problem that I am facing is with multithreading. One of the API calls is made using a DispatcherTimer every 60 seconds. The issue is that when this event fires, it blocks t...

mergeChangesFromContextDidSaveNotification taking almost a minute

I have a managed object context in a separate thread that is creating a few hundred managed objects, and when it saves, the did save notification is passed to the main thread and my other context (on the main thread) is updated: In Thread [ApplicationDelegate performSelectorOnMainThread:@selector(managedObjectContextDidSave:) ...

.NET Garbage Collection and Native Threads

It’s fairly well documented that when .NET's automatic garbage collector runs, it will temporarily pause all running managed threads associated with the application domain. What I haven't been able to discover are details on what happens to native threads created by the application when garbage collection occurs (ie. using _beginthreadex...

Running background processes after a web request

I'm interested in kicking off processes after a web request, or possibly forking a new process after the initial thread is finished. I would prefer not to use a cron, because of the nature of the the jobs I'll be running and how often they need to be run, waiting a minute to refresh is not an option. I'm considering a few ways of doing...

Eclipse RCP: Only one Job runs at a time?

The Jobs API in Eclipse RCP apparently works much differently than I expected. I thought that creating and scheduling multiple Jobs would actually cause multiple worker threads to be created, executing the Jobs in parallel unless there was an ISchedulingRule conflict. I went back and read the documentation more closely, and also discove...

How to force screen update for list view from non-UI thread (iPhone)

I have a background thread listening to network, using a callback to process and store data. When it's ready (UI) controller gets a sync Notification, requests data, updates list and refreshes screen ...except screen doesn't update - until user scrolls the screen! void aMessageArrivedCBack (const std::string text) { NSAutoreleasePoo...

sql table cell modified by multiple threads at the same time

if you have table BankAccount that has a column Amount and the value for this column for a specific row can be modified by multiple threads at the same time so it could happen so that the last one to set the value will win. how do you usually handle this kind of situations ? UPDATE: I heard that in MSSQL there is update lock UPDLOCK th...

Create thread with specific privilege c++

hello I have multi-thread application that I want to create a thread with different user privilege (for example : multi domain admin privilege). but I can't find any Win32 API CreateThread to do that. How to create thread with specific user privileges? thanks. ...