multithreading

C# - Improving a Multi-Threaded Application Design.

Specification C# Distributed Application. Client/Server design. Client (Winforms), Server (Windows Service), Communication via .Net Remoting. The below question relates to the Server-Side of the application. (EDIT) The Server-side of the application runs on a server with 8 Cores and 12Gb Ram (EDIT) The CPU of this server is always hitt...

Question about g_io_scheduler_job_send_to_mainloop

Hello, I have functiof of load data: GdkPixbufAnimation* load_image_from_stream(GInputStream* input_stream, GCancellable* generator_cancellable) { .... } It's load very nice. Then I have function where i call load_image_from_stream: void loading(GtkWidget* widget ,MainWin* mw) { GInputStream* input_stream; input_strea...

Named/System mutex in Java

I'm re-working a Java executable that may be started multiple times, and I want the process to proceed one at a time. In C# I would do this with a named/system Mutex, but this doesn't seem to be possible in Java. How can I achieve this functionality? ...

How to stop a java thread gracefully ?

I wrote a thread, it is taking too much time to execute and it seems it is not completely done. I want to stop the thread gracefully. Any help ? ...

How to disconnect a bluetooth connection (HTC Desire)

Hello everyone, I need to connect my android to a bluetooth device. I use the BluetoothChat sample from Google. I had some trouble to do this with a Google Nexus one, because the Nexus was making the connection but disconnects right after. I need to initiate twice time the connection as workaround (see connectionLost()). Now, it works...

Thread timeout in c#

Hi, I'm new to threading in C#. Is there anyway of setting a timeout for a thread without blocking the calling thread (in C# 3.5)? If not, is it logical to execute a function using a thread and within that function create a thread and join it to overcome this main thread blocking issue? To illustrate: Instead of: Public void main() { ...

How expensive is creating of a new thread in Java? When should we consider using of a thread pool?

I wonder where is the verge after which a thread pool should be used. How many new threads per second can I create without using a thread pool still avoiding noticeable performance penalty? Are there any observable open-source thread-pool implementations? ...

COM type library and Interface exposure

When you have a COM client that exposes an Interface for an out of proc COM server to access, do you have to register the type library or .idl file with the system for the server to be able to access the interface? I'm not sure if I can generate a proxy/stub DLL from this client process to register with the system. Does it matter in wh...

C#: Showing a modal progress dialog during a long process

My software requires to store the directory and registry structure for some particular locations. This usually takes a long time. Let's say I have a method called SaveState() which does that. I want to wrap this into another method, SaveStateWithProgress(), so that when I call it, a modal dialog appears, which shows a simple progress ba...

Multithreaded file writing

Guys, I am trying to write to different pieces of a large file using multiple threads, just like a segmented file downloaded would do. My question is, what is the safe way to do this? Do I open the file for writing, create my threads, passing the Stream object to each thread? I don't want an error to occur because multiple threads are ...

C#: Query status of a thread

I am running a background worker thread that takes a long time to run. The actual function stores the folder structure of a location, but we can take an example of the following pseudo code running in a different thread - private int currentResult=0; private void worker() { for(int n = 0; n<1000; ++n) { int result; ...

C threading in linux?

Does someone have a simple example of threading in c? I want to build a small console app that will read a txt file file line by line and then use threads to process the entire txt. How should I do this? splitting the txt into X where X=N of threads, is the first thing that comes to my mind, is there a better way? ...

C++ MySQL and multithreading - 1 DB connection per user?

Hi, Is in multithreaded application suitable to have 1 connection per 1 connected client? To me it seems ineffective but if there is not connection pooling, how it could be done when one wants to let each connection communicate with DB? Thanks ...

Java Executors: how can I set task priority?

Is there a possibility to set priority to tasks which are executed by Executors? I've found some statements in JCIP about it's possible but I cannot find any example and I cannot find anything related in docs. From JCIP: An execution policy specifies the "what, where, when, and how" of task execution, including: ... ...

Robot.delay(int) versus Thread.sleep(long)

I have a program whose only purpose is to drive a java.awt.Robot in an infinite loop until an exit condition is met. The robot performs a number of actions in quick succession, which require a standard UI delay between them. For this, I use java.awt.Robot.setAutoDelay(int ms), which appears to be designed for precisely this purpose. At...

Java synchronization problem

Hi, I have two threads and one class. Thread1 updates the local object of the class via 3 different methods. The local object (behind the scene) uses some sort of ArrayList to store data. Three methods (mentioned earlier), are doing something with elements of the list... Thread2 queries the local object (content of array list). PROBL...

Need comprehensive C# System.Threading.Tasks example

Hi! I've been trying to figure out how to use System.Threading.Tasks to asynchronously invoke a synchronous WCF method while supporting cancellation, error handling, result-return and multiple continuations. I've come across a number of incomplete demos but they all seem to fall a bit short. As an example I can't use cooperative cancel...

C++ timeout on getline

I need all of my threads to check periodically that they should still be running, so that they can self-terminate when the program ends. For all but one of them, this is just a matter of checking a state variable, but the last one is a user-interaction thread, and its loop will wait indefinitely on user input, only checking the state var...

Windows Forms unhandled error pop up message

I have a windows forms application (.NET C# 3.5)... that is throwing an error.. but I have 2 scenarios: Client: on the client side.. the error is logged into a log.txt file.. AND an error pop up message appears See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ***** Ex...

Synchronizing access to a return value

Consider the following C++ member function: size_t size() const { boost::lock_guard<boost::mutex> lock(m_mutex); return m_size; } The intent here is not to synchronize access to the private member variable m_size, but just to make sure that the caller receives a valid value for m_size. The goal is to prevent the function f...