multithreading

.net application multi-threading

I have a multi core cpu but the .net app i wrote only uses one of the cores. how can i make it use more than one core when that option is available. ...

Self-repairing Python threads

Hi guys, I've created a web spider that accesses both a US and EU server. The US and EU servers are the same data structure, but have different data inside them, and I want to collate it all. In order to be nice to the server, there's a wait time between each request. As the program is exactly the same, in order to speed up processing, ...

C# thread interruption stopped working

I dont know why but i can no longer interrupt my own thread. thread = new Thread(new ParameterizedThreadStart(this.doWork)); thread.Start(param); ... thread.Interrupt(); //in doWork() try { ... } catch (System.Threading.ThreadInterruptedException) { //it never hits here. it use to } I search and i dont have any catch in my code and t...

Thread-safe one time calculation best practices

It's quite common that I need a property in my class which needs to be calculated and cached. Generally I use a lock and a boolean top check if it's processed or not. Sometimes I do it in accessors. What's the performance hit of this approach? Is there any better way to it. Sample Code of my common approach to this: Sub Main() ...

Is this an appropriate use of the ThreadPool? Can I be sure it'll start a thread for each task?

protected override void OnStart(String[] args) { ResultManager.PrepareCache(); ThreadPool.QueueUserWorkItem(ResultQueue.Process); ThreadPool.QueueUserWorkItem(StatusUpdater.UpdateStatus); ThreadPool.QueueUserWorkItem(GeneralQueue.RestartHungTests); ThreadPool.QueueUserWorkItem(ResultManager...

Lua registry not visible from new states

In a C function called from my Lua script, I'm using luaL_ref to store a reference to a function. However, if I then try to use the returned integer index to fetch that function from a different thread which isn't derived from the same state, all I get back is nil. Here's the simplest example that seems to demonstrate it: // Assumes a v...

Multi-threading and Java Swing Problem

Hi I have a GUI application that is working fine. I created a socket server. When I create a new object of the Server class in program the GUI application stops responding. This is my server class. If I do Server s = new Server(); in my main application it stops working. How should I add it? Making a new thread? I tried Thread t...

C# Am i using lock correctly?

I'm currently trying to write a thread-safe logger class. I'm not very familiar with correct design and best practices in this area. Is there a flaw in my code? public class WriteStuff { private readonly StreamWriter m_Writer; private readonly object m_WriteLock = new object (); public WriteStuff(String path) { m_Writer = File.Cr...

Generify-ing The .NET Background Worker

We're working on a Windows App that periodically has to launch operations which may take some time. We've gotten into a pattern of having these operations run on a BackgroundWorker, and writing up a quick WinForm for each operation, where you pass in to the form the necessary parameters, the form wires up the BackgroundWorker and makes ...

GUI update when starting event handler class on separate thread?

We have a DLL that monitors changes in status and looks for events from a separate, purchased product. Actually, it is a ScreenPop API from Siemens, for those of you who may know what that is. I am using C#.NET 3.5 as the platform. This API takes a looong time to initialize, so we want to use a separate thread to initialize it. Curre...

What's the best way to propagate information from my wx.Process back to my main thread?

I'm trying to subclass wx.Process such that I have a customized process launcher that fires events back to the main thread with data collected from the stdout stream. Is this a good way of doing things? class BuildProcess(wx.Process): def __init__(self, cmd, notify=None): wx.Process.__init__(self, notify) print "Const...

Does memory stay allocated when a C++ thread exits?

I'm using the pthread library on Linux. I'm assigning a string in thread A, and then trying to print the string in thread B. However, the string just prints out empty (I have verified that it works in thread A). Note: The string resides inside an object, which I suspect may be getting cleaned up or re-instantiated empty... The containe...

Updating UI from a different thread

Hi, I know this question has been asked before, but I feel it wasn't asked correctly. I have an intensive operation and I'd like the UI to remain responsive. I've read a few posts that say Background worker is the best way to go, however, I think this assumes you have the source code to the intensive task. I have a library that I have...

How to use safe threading for a timer(Change timer properties from different thread)

Hello, To access a memo on my form,I use the following code public string TextValue { set { if (this.Memo.InvokeRequired) { this.Invoke((MethodInvoker)delegate { this.Memo.Text += value + "\n"; }); } ...

Richtextbox.invoke, C#, Form Still hanging

I've written a c# application to run an external program and i've redirectet it's output to a richtextbox in my form. I've created the process using the following settings p1.StartInfo.RedirectStandardOutput = true; p1.OutputDataReceived += new DataReceivedEventHandler(outputreceived); and in the outputreceived event void outputrecei...

What are the Dangers of using a Singleton in a multithreaded application

I'm looking at using a singleton in a multithreaded Win service for doing logging, and wanted to know what are some of the problems I might encounter. I have already set up the get instance to handle syncing with private static volatile Logging _instance; private static object _syncRoot = new object(); private Logging(){} ...

Is using a Windows handle to make DirectX calls from bgnd thread safe?

I am debugging an app that is (mostly) a Winforms UI on top of unmanaged code. A little bit of the UI code is not WinForms: it is using DirectX to draw directly onto the surface of some Panel components. In order to do so, the windows handle of the component is recorded after it is created, and any subsequent calls requiring a handle tha...

Regarding Terracotta and Servlets/ Shared Threads.

I have a system that I need to distrubte that works as follows. Servlets served by tomcat start up and spawn off threads with a large number of shared (distributed) fields. Ergo, I set the thread as a root and attempt to spawn the threads as normal from my servlet constructor. However, logging indicates that the Runnable I'm attempting t...

How do I prevent static member variables from being accessed by more than one request at a time in IIS?

I’m having some trouble with understanding how IIS is handling static variables on its threads. My understanding has always been that if IIS has 4 worker processes that it can handle 4 requests simultaneously and that it would be the same as having 4 separate threads running the website. Any static variables would persist in each indi...

Question on safety of instance fields and thread origins

In C#, a class field means every thread has its own instance of that object. E.g. thread 1 will have its own instance of object a, as will object b. So 2 users of a web application, on different PCs, should be accessing an instance field (Say a collection) under different, threads, right? This makes me beg the question, why would I ne...