multithreading

Can I Open Multiple Connections to a HTTP Server?

Hi All, I’m writing a small software component in order to download resources from a web Server (IIS). But it seems like that system's performance is not acceptable. Now I’m planning to increase the number of connection to the web server by spawning multiple threads. My question is, can I improve performance by using multiple threads?...

C# Timer vs Thread in Service

Hi, I have a Service that hits a database every 10 sec and gets the data if there is any. The thing is that processing this data can take up to 30 sec. If I use a Timer with 10 sec interval the service will get the same data twice. The effect i´m trying to achieve(Just for visualization): while(true) { if(Getnrofrows() > 0) ...

Threading run time without adding extra lines in program

Is there any thread library which can parse through code and find blocks of code which can be threaded and accordingly add the required threading instructions. Also I want to check performance of a multithreaded program as compared to its single thread version. For this I would need to monitor the CPU usage(how much each processor is g...

Generic approach to NSManagedObjectContext in multi-threaded application

I've read a number of posts here about NSManagedObjectContext and multi-threaded applications. I've also gone over the CoreDataBooks example to understand how separate threads require their own NSManagedObjectContext, and how a save operation gets merged with the main NSManagedObjectContext. I found the example to be good, but also too...

Which approach to take with this multithreading problem?

Short question: I would like to spawn a single background thread that would process work items submitted to a queue (like a threadpool with one thread). Some of the work items are capable of reporting progress, some are not. Which one of the .NET's myriad of multithreading approaches should I use? Long explanation (to avoid asking ab...

Backgound task of filling grid with images hanging

I'm pretty sure my problem is going to be due to lack of knowledge with threads etc. but anyways: I have a reference to a Grid object, which I'm filling with images via a list<list<image>> (columns<rows>). _gridToFill.Dispatcher.Invoke(new Action(delegate() { foreach (Image i in s) { _gridToFill.Children.Add(i); } } I...

Pausing main game thread until an Activity is started, and has finished - Android

Hi there In my game when the user completes a stage, I want the main game thread to pause/sleep/wait and a new activity to be launched called StageClear that displays information about points scored etc. After this has been displayed and the user has pressed continue I want the original game thread to resume where it left off. I have tr...

How to perform sequential file write in separate thread

I am given some data in a callback function to write to disk sequentially, about 4KB every 0.02 seconds. If I fwrite() from the thread the callback function is in, I get some lag in other parts of code in same thread. So in order to not block this thread while writing to disk, I want to move the fwrite code to another thread. The problem...

Why does this simple .NET console app have so many threads?

This simple program starts with 15 threads - according to the count. Sometimes during its lifetime it drops a few, but they come back. class Program { static void Main(string[] args) { while (true) { Console.WriteLine(Process.GetCurrentProcess().Threads.Count); Thread.Sleep(500); ...

Some help with TThread (Terminate, FreeOnTerminate and other adventures in the realm of threading)

Hello all, I'm trying the achieve the following (using Delphi7): After logging in to my program, the user gains control, but in the background a separate thread downloads a file from the Internet to check if the current license key is blacklisted. If it is, the user receives a prompt and the program terminates. So I've created a separa...

Blocking a Thread in .Net

I have a class that has purely static Methods and properties. I am calling an async method on the class "Load" that asks a web service for a chunk of data, which then fires an event that executes the return method, "LoadCompleted". I have no idea how long the call is going to take (the difference between calling the "Load" method, then ...

All threads doing same job

I want to write network address to my listview, in a range like 192.168.0.0 -192.168.255.255 and I wrote a thread application but when I run this app, all threads are trying to add addresses to listview, does it has a simple solution? here is my code: namespace ListNetworkComputers { public partial class frmMain : Form { ...

Spring bean thread safety

I am declaring a Spring bean for a Java class that is used as a factory to create objects. I want to use this factory from different threads, the problem I am experienced is that threads are blocked when they try to create an object using the factory. As far as I know spring beans are singletons by default, and this is what I want. I wa...

Can this code be refactored by using the reactive framework ?

Hi all, copy paste the following code in new C# console app. class Program { static void Main(string[] args) { var enumerator = new QueuedEnumerator<long>(); var listenerWaitHandle = Listener(enumerator); Publisher(enumerator); listenerWaitHandle.WaitOne(); } private static AutoResetEve...

Custom implementation of Thread in Java: Is it possible though JNI?

Would it be possible to implement a custom Thread class in Java (using JNI) in a safe / correct way? Suppose I write my own NewThread class, with a native start() method, which forks the execution, calls run() in the forked thread and returns... Is that possible? Would the JVM complain? Is it "legal" according to the specs? Would this ...

Closing form from different thread happening too soon, causing exception

I've got the following situation, Private Sub MyButton_Click(sender as Object, args as EventArgs) Handles MyButton.Click Me.pleaseWaitFrm = New PleaseWaitForm() ' Fire up new thread to do some work in (AddressOf DoMyWork) Me.pleaseWaitFrm.ShowDialog() End Sub Private Sub DoMyWork() Dim log = Me.DoTheActualWork() Me.p...

Can not call getApplicationContext() inside a thread.

Hello all, I am developing an application on Android Froyo system, everything is fine, except that when I create a service, and the service will spawn several thread. In one of the thread, I want to stop the service. Apparently stopService() is out of scope in the thread class, and so is the getApplicationContext() calls. So inside a th...

Time limiting a method in C#

I have a Game framework where there is a list of Bots who implement IBotInterface. These bots are custom made by user with the only limitation that they must implement the interface. The game then calls methods in the bots (hopefully in parallel) for various events like yourTurn and roundStart. I want the bot to only spend a limited am...

How can I make this prime finder operate in parallel

I know prime finding is well studied, and there are a lot of different implementations. My question is, using the provided method (code sample), how can I go about breaking up the work? The machine it will be running on has 4 quad core hyperthreaded processors and 16GB of ram. I realize that there are some improvements that could be m...

Invoke a delegate on a specific thread C#

Is there any way to get a delegate to run on a specific thread? Say I have: CustomDelegate del = someObject.someFunction; Thread dedicatedThread = ThreadList[x]; Can I have a consistent background long running thread and invoke my own delegates on it whenever I need it. It has to be the same thread each time. [Edit] The reason why...