multithreading

Easy Threading in WPF

Hi everyone, I've been reading a lot about threading in C#, WPF and Silverlight but can't get it to work. My main problem is I have the _load (_Initialized) action and it has a lot of object creation and along with that I have timers working doing different things, this causes the startup time of the program to be very slow and obvious...

Java socketserver: How to handle many incoming connections?

I am writing a simple multithreaded socketserver and I am wondering how best to handle incoming connections: create a new thread for each new connection. The number of concurrent threads would be limited and waiting connections limited by specifying a backlog add all incoming connections into a queue and have a pool of worker threads...

how to share a variable between two threads

I just inherited some code, two threads within this code need to perform a system task. One thread should do the system task before the other thread. They should not be performing the system task together. The two threads do not have references to each other. Now, I know I can use some sort of a semaphore to achieve this. But my questi...

How to make an HTTP request in a separate thread with timeout?

Hi, I haven't programmed in Delphi for a while and frankly didn't think I'll ever have to but... Here I am, desperately trying to find some information on the matter and it's so scarce nowadays, I can't find anything. So maybe you guys could help me out. Currently my application uses Synapse library to make HTTP calls, but it doesn't a...

Race condition during thread start?

Hi, I'm running the following code to start my threads, but they don't start as intended. For some reason, some of the threads start with the same objects (and some don't even start). If I try to debug, they start just fine (extra delay added by me clicking F10 to step through the code). These are the functions in my forms app: privat...

access list element from thread

I have a "List" in the main application and I am trying to access its elements from within a thread. I am getting this exception: {"The calling thread cannot access this object because a different thread owns it."} System.SystemException {System.InvalidOperationException} ...

Why Does my Thread Terminate Immediately After Showing a Windows Form?

I have a Windows Form Application (Form1) that allow the user to open another Forms (FormGraph). In order to open the FormGraph App I use a thread that open it. Here is the code that the thread is running: private void ThreadCreateCurvedGraph() { FormGraph myGraph = new FormGraph(); myGraph.CreateCurvedGraph(...); myGra...

BitmapFrame in another thread

Hi I am using a WPF BackgroundWorker to create thumbnails. My worker function looks like: private void work(object sender, DoWorkEventArgs e) { try { var paths = e.Argument as string[]; var boxList = new List<BoxItem>(); foreach (string path in paths) { if (!string.IsNullOrEmpty(path)) ...

Is Java class initialized by the thread which use it for the first time?

Lets assume following classes definition: public class A { public final static String SOME_VALUE; static { SOME_VALUE = "some.value"; } } public class B { private final String value = A.SOME_VALUE; } Assuming that the class A hasn't been loaded yet, what does happen when object of the class B is instantiated ...

Is loading a video in a browser multithreaded?

It's hard to know what is multithreaded in a browser and what isn't. It seems while a video streams or progressively downloads, it does not affect page performance, so my guess it is. Note I'm using Flash video, but it's really about video in general. Any other tips on what else is multithreaded (image loads?) is also helpful. I know Ja...

Python: nonblocking read from stdout of threaded subprocess

I have a script (worker.py) that prints unbuffered output in the form... 1 2 3 . . . n where n is some constant number of iterations a loop in this script will make. In another script (service_controller.py) I start a number of threads, each of which starts a subprocess using subprocess.Popen(stdout=subprocess.PIPE, ...); Now, in my...

Tagging and how to test a tag exists

I plan to store tags (like the ones on Stackoverflow) using the Toxi scheme Tags are stored in a separate table. create table tags ( tagSeq int unsigned, name varchar(255), PRIMARY KEY (tagSeq), UNIQUE INDEX (name) ); In the add a tag usecase, multiple concurrent threads will be attempting to check if a particular tag exis...

multithreading issue

I have written a multithreaded crawler and the process is simply creating threads and having them access a list of urls to crawl. They then access the urls and parse the html content. All this seems to work fine. Now when I need to write to tables in a database is when I experience issues. I have 2 declared arraylists that will contain t...

C# Basic Multi-Threading Question: Call Method on Thread A from Thread B (Thread B started from Thread A)

What is the best way to accomplish this: The main thread (Thread A) creates two other threads (Thread B and Thread C). Threads B and C do heavy disk I/O and eventually need to pass in resources they created to Thread A to then call a method in an external DLL file which requires the thread that created it to be called correctly so only T...

Difference between SwingWorker and SwingUtilities.invokeLater

I need to run some method in Swing application in separate thread. What is the difference between using SwingWorker and SwingUtilities.invokeLater. Which one should I use to run a thread in Swing application? I couldn't find exact info in the tutorial at http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html ...

What is the difference between SynchronizationContext.Send and SynchronizationContext.Post?

Thanks to Jeremy Miller's good work in Functional Programming For Everyday .NET Development, I have a working command executor that does everything I want it to (do heavy lifting on the thread pool, send results or errors back to the synchronization context, and even post progress back to the synchronization context), but I can't explain...

C# threading pattern that will let me flush

I have a class that implements the Begin/End Invocation pattern where I initially used ThreadPool.QueueUserWorkItem() to thread my work. The work done on the thread doesn't loop but does takes a bit of time to process so the work itself is not easily stopped. I now have the side effect where someone using my class is calling the Begin (...

Java socketserver using Apache Mina - how to set up threading?

I am building a socketserver using Apache Mina and I am trying to make sense of configuring the thread model. I am currently reading: http://mina.apache.org/configuring-thread-model.html As I understand it; it is best to use multithreading for each IOService, something like: SocketAcceptor acceptor = new SocketAcceptor( Runtime...

Instantiating a System.Threading.Thread object in Jscript

I'm trying to create a new System.Threading.Thread object using Jscript, but I can't get the constructor to work. If I just do the following, var thread = new Thread( threadFunc ); function threadFunc() { // do stuff } then I get error JS1184: More than one constructor matches this argument list. However, if I try to coerce thr...

SQL Server stored procedure in multi threaded environments

Hi, I need to execute some Sql server stored procs in a thread safe manner. At the moment I'm using software locks (C# locks) to achieve this but wonder what kind of features provided by the Sql server itself to achieve thread safety. It seems to be there are some table and row locking features built in to Sql server. Also from a perf...