I have started a process in my Java code, this process take a very long time to run and could generate some output from time to time. I need to react to every output when they are generated, what is the best way to do this?
...
I'm updating legacy code, written in VB6, and I've come across the need for a mutex. I have two sockets, and I need to send and receive from various sources. So I plan on having one socket continuously listening for incoming connections, then the other is used to send or receive.
A timer checks twenty times a second if a connection has ...
Don't understand, where do I get this wrong. If compiled without openmp support, the code works correctly. But with openmp variables seem to get wrong visibility.
I had the following intention. Each thread has its own max_private in which it finds the local maximum. Then a global maximum is found in a critical section.
#include <iostre...
I am running a Java process on unix.
I need to run an external process which is spawned by the main process using ProcessBuilder. The main process waits until the external process is done, and then spawnes the next external process. I have got it working till here.
public static void main(String[] args) {
for(...) {
int ...
I'm struggling to understand why nothing is output using the following:
class Program
{
static int m_Active = 500;
static void Main(string[] args)
{
ThreadPool.SetMaxThreads(5, 5);
Enumerable.Range(1, m_Active).ToList<int>()
.ForEach(i => ThreadPool.QueueUserWorkItem((o) => { DoWork(i); }));
}...
I want to get alive or dead ip addresses from a big lan. but it takes so many times. I decided to use backgroundworker here is my code:
try
{
this.Status.Text = "Collecting Information...";
if(this.TxtWorkGroup.Text.Trim() == "")
{
MessageBox.Show("The Work Group name Should Not be Empty");
return;
}
...
Hi All,
I'm using MVVM Light to build a WP7 (Windows Phone 7) application. I wish to have all the work performed by the Model to be run on a background thread. Then, when the work is done, raise an event so that the ViewModel can process the data.
I have already found out that I cannot invoke a Delegate asynchronously from an WP7 app....
I have a fixed thread pool that I submit tasks to (limited to 5 threads). How can I find out which one of those 5 threads executes my task (something like "thread #3 of 5 is doing this task")?
ExecutorService taskExecutor = Executors.newFixedThreadPool(5);
//in infinite loop:
taskExecutor.execute(new MyTask());
....
private class MyTa...
Hi All,
I haven't used any of Spring's threading support before. Does it support any high level concept of the Thread class's wait and notify?
...
My app takes a loooong list of urls, and split it in X (where X = $threads) so then I can start a thread.php and calculate the urls for it. Then it does GET and POST request to retrieve data
I am using this:
for($x=1;$x<=$threads;$x++){
$pid[] = exec("/path/bin/php thread.php <options> > /dev/null & echo \$!");
}
For "threading"...
I am writing an iPhone application, and I need to download files in the background. I can handle the download files part, but I am not so sure about the background part. My current idea is to use a run loop to wait until the user selects a file to download. This appears to work, but a run loop exits if no input source is set. However...
I've run into an while trying to launch an NSTask from inside an NSOperation.
Here's a very simple app I've put together to showcase the problem. When you click the button, an NSOperation is queued. It sets up an NSRunLoop, and calls a method which invokes an NSTask. The task is really simple- it just launches /bin/sleep for two seconds...
Being new to using threads etc in UI's, can I ask is the following simple design seem OK. Refer to diagram image at link here
In particular:
a) use of backgroundworker & backgroundworker ProgressChanged to have the aggregator work on a separate thread. So I would need a custom class/type that had all the data I'd need to pass back fro...
I got a thread running every few seconds fetching some data from a db
but this is based on the selection on a listbox and on a few checkboxes...
can I read the values of these controls without using the GUI thread?
The data is also read whenever one of the controls change, but the data might change in db
without warning...hence the thre...
How should I check for a CancellationPending within a BackgroundWorker DoWork method, when within this method I call off to a Pcap.Net packet capture routine, which responses via a callback. The two options I can think of is:
a) write a loop at the bottom of the DoWork method to continually check for CancellationPending
b) put the che...
Hi,
Is my use of ConcurrentQueue here between 2 threads ok? I wanted to check I don't need to "lock" anywhere explicitly. In particular look at the lines where I have in COMMENTS would I drop a packet here...
public class PacketCapturer
{
private static ConcurrentQueue<Packet> _packetQueue = new ConcurrentQueue<Packet>();
public Pa...
I've a JDialog with a JLabel. I want to change the value of label every 10 seconds.
How can I redraw/repaint the JDialog with updated value in JLabel.
...
I am having a weird concurrency issue with Python on Cygwin. I am running two threads:
A thread which sends UDP packets at regular intervals
A main thread which waits for KeyBoardInterrupt and when it receives one, it tells the UDP thread to stop sending via a boolean flag
This works just fine under Linux (python 2.6) and Windows (Py...
I'm creating three threads in one of my application. The requirement I have is that the method that creates these three threads and starts them off should not return unless all these three threads are executed.
I tried to use Join on all three threads. However, I observe that when I use Join the total execution time of my method is the ...
Is it possible to change CurrentUICulture of main thread when event is raised in worker thread?
Code for ilustration:
static void Main()
{
//do something
Thread workerThread = new Thread(new ThreadStart(DoWork));
workerThread.Start();
//do something
}
void DoWork()
{
ConnectDatabase();
//do some work
ChangeLangua...