multithreading

Ensuring Thread Safety

I am in the midst of writing a C# Windows Form application that processes quotes from the market through an algorithm (strategy) to create orders to a brokerage firm. That all seems to be testing fairly well until I tried to build in the capacity to run multiple strategies simultaneously with each strategy on it's own thread. At this p...

Cancel NamedPipeClientStream.Read call

I've looked around all over the web, but I can't find an answer to the following question. I have a C#/.NET NamedPipeClientStream instance in a client program, and a worker thread is calling NamedPipeClientStream.Read(byte[], int, int) to get data from a server. The server sends data updates to the client. Read is a blocking call. If...

Few confusing things about locks

I know how to use locks in my app, but there still few things that I don't quite understand about locking ( BTW - I know that the lock statement is just a shorthand notation for working with Monitor class type ). From http://msdn.microsoft.com/en-us/library/ms173179.aspx: public class TestThreading { private System.Object lockTh...

Starting multiple gui (WinForms) threads so they can work separetly from one main gui in C#?

I've one MainForm window and from that user can press 3 buttons. Each of the button starts new Form in which user can do anything he likes (like time consuming database calls etc). So i decided to put each of the forms in it's own threads: private Thread subThreadForRaportyKlienta; private Thread subThreadForGeneratorPrzelewow; ...

I cant get UIScrollView and UIAccelerometer to play nice, even with threading

problem is, everytime i go into my application and scroll around inside the scrollview, everything else in the program is completely useless, and tills I stops me scrolling, the accelerometer, and not to mention everything else wont do a thing, if anyone has any idea how i can get around said problem, id be much obliged, yes I would. an...

Running a loop (such as one for a mock webserver) within a thread

I'm trying to run a mock webserver within a thread within a class. I've tried passing the class' @server property to the thread block but as soon as I try to do server.accept the thread stops. Is there some way to make this work? I want to basically be able to run a webserver off of this script while still taking user input via stdin.get...

GC with C# and C++ in same solution

I have a solution consisting of a number of C# projects. It was written in C# to get it operational quickly. Garbage collections are starting to become an issuewe are seeing some 100 ms delays that we'd like to avoid. One thought was to re-write it in C++, project by project. But if you combine C# with unmanaged C++, will the threads...

Problem in displaying the message and the progress at the same time,threading in MFC?

Hello friends, I am working on threading in MFC..I am not sure how to use threading.. I cant attain what i excepted!What I actually tried, is to read the directory and display the file names and at the same time,the progress control should show the progress..I created a dynamic static to display the file names and progress ...

C# threading problem

i am trying to simplify problem as follows, i have around 100+ files that i would like to read and then process the data For which i maintain array of file names and location I spawn threads to do the job of reading files. Now my problem is i would like to make sure that only 5 threads are spawn at a time as starting 100 + threads is...

Timer get interval time

Hi, I created a Timer private static AutoResetEvent autoEvent; private static Timer stateTimer; public static void Start() { autoEvent = new AutoResetEvent(false); TimerCallback timerDelegate = new TimerCallback(SomeClass.TimerLoad); stateTimer = new Timer(timerDelegate, autoEvent, 1000, 3 * 60 * 60 * 1000); } from other ...

Using Multithreading in Java to read data

I'm trying to think how should I utilize threads in my program. Right now I have a single threaded program that reads a single huge file. Very simple program, just reads line by line and collects some statistics about the words. Now, I would like to use multi threads to make it faster. I'm not sure how to approach this. One solution is...

Please post any example for threading in MFC?

guys please post me an example for threading in MFC....it should show the progress and at the same time it should display the text,,if u anyone know some examples, please post me... ...

Discussion with a sub-process, using Ruby with IO and threading

Hi everyone, I am trying to use IO.popen in order to put (with .puts method) and to get (with .gets method) messages from a process to its sub-process. I am not very experimented and I have a question about. Having the following code, I have an error because it is not possible to write in a closed stream. class Interface def initia...

Problem with console.

I am just learning how to work with threading mechanism in C#. I took a example from msdn and altered it to design a simple game like this. But the problem is the while loop in DoWork method is reading keys even before DoWork Method is called from main program. I,e. When you run the program before "Go:" appears on the screen if you ty...

If I allocate memory in one thread in C++ can I de-allocate it in another

If I allocate memory in one thread in C++ (either new or malloc) can I de-allocate it in another, or must both occur in the same thread? Ideally, I'd like to avoid this in the first place, but I'm curious to know is it legal, illegal or implementation dependent. Edit: The compilers I'm currently using include VS2003, VS2008 and Embedd...

WPF access GUI from other thread

Hi, I am working through the requirement to make a WPF Application single instance only. However - I have to pass the command line to the first instance and then perform some UI action. I am using a Mutext to check for already running instances, I do use NamedPipes to transfer the command line to the already running instance. But of ...

process list items in different threads

At the moment I have List of Job objects that are queued to be processed sequentially shown in the code bellow. List<Job> jobList = jobQueue.GetJobsWithStatus(Status.New); foreach (Job job in jobList) { job.Process(); } I am interested in running several Jobs at the same time in a limited number of t...

how do I handle messages asynchronously, throwing away any new messages while processing?

I have a C# app that subscribes to a topic on our messaging system for value updates. When a new value comes in, I do some processing and then carry on. The problem is, the updates can come faster than the app can process them. What I want to do is to just hold on to the latest value, so I don't want a queue. For example, the source publ...

Triggering an event every second

I have an application that needs to check a website feed every second. Sometimes the request to the server is longer than a second. In this case, the application needs to wait until the first request completes, then start a new request immediately. How could I implement this? Also, the request should not freeze the GUI. ...

approach using thread programming

This is my scenario. I have a pool of frequencies and my BaseStation needs to select one of them. The critical section for a BaseStation is the phase when it goes into frequency selection. Once it selects frequencies, control returns back to the main BaseStation class and it resumes its request generation. At the same time, i.e. as soon...