Run a task for two seconds without blocking the user interface

I'm writting a VB.Net app that interacts with a CAN bus in order to control some motors that are on it. With the CAN bus I can turn on and off each motor, in normal and reverse mode, and read their current consumption. I have implemented two checkbox

Passing entire arguments to the main function in C

My question is how to pass int arguments through argv[]. The form I want to use is the following: while the NTHREADS, and LETTER can be optional, the FILE1 must be provided. ./test [-t NTHREADS] [-l LETTER] FILE1 How can I handle this?You can't. All

Synchronous parallel process in C # / C ++

I have an array x[] containing data. Also there is an array of "system states" c[]. The process: for(i = 1; i < N; i++) { a = f1(x[i] + c[i-1]); b = f2(x[i] + c[i-1]); c[i] = a + b; } Is there any efficient way to find the values of f1 and f2

MVC - System.Threading.ThreadAbortException in a parallel task

In my MVC application, a superadministrator can set a queue of tasks such as updating database. So, when an admin adds an update to the queue, the controller starts a new tasks that works in a background. However, when you add a few tasks, the applic

Thread with while (true) sort of sort

I have a thread that is supposed to run continuously in my program and parse incoming serial data from a collection of sensors. //initialized as a global variable System.Threading.Thread processThread = new System.Threading.Thread(ProcessSerialData);

Thread safety in Objective-C categories

I have a category on NSString: - (CGSize) agb_sizeWithFont:(UIFont *)font width:(CGFloat)width lineBreakMode:(NSLineBreakMode)lineBreakMode { if (!font) return CGSizeZero; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] ini

How long does thread creation and termination take on Windows?

I've split a complex array processing task into a number of threads to take advantage of multi-core processing and am seeing great benefits. Currently, at the start of the task I create the threads, and then wait for them to terminate as they complet

How to kill a thread in Android?

I've got a background thread running in my application and I need to kill it safely. How can I kill a thread in java other than using a boolean flag? I have read that i cannot use thread.stop() anymore as it is not safe. but is there a proper way of

Connecting to the multi-serial COM port using multithreading

We have a research that requires a server (using sockets) to have com ports with cisco device connected to it. The problem is I can not initialize multiple threads. Here is a code on how we initialize the Thread for a com port. public CLI(String port

Using ThreadLocal vs Atomic

According to ThreadLocal's javadoc, it sounds like its a thread-specific container for 1+ atomic fields. Is the purpose of ThreadLocal to represent all the atomic fields for a single Thread, or is it to just provided a convenience container when you

to suspend pthread?

I want to implement a mutex lock. From my understanding, mutex.lock() should work like 1) check lock owner 2) if lock is owned, put thread in waiting queue 3) suspend this thread until another thread send a wait up signal However, there is nothing li

ReentrantLock.tryLock () not lockable

I think I just am not seeing something as I've gotten this to work in the past. My lock isn't holding an exclusive lock, and when a new instance of the object is created, tryLock returns true and another TimerTask is scheduled. public class A { priva

Events Between Number of C ++ Threads

If I want thread A to receive its packets and process them, and some thread B can at some point change the socket's IP address. So the thing that need to be done here is: Thread A must start on listening on the new IP and thread B must somehow tell t

Should threads reside outside the thread pool?

When using a thread pool, is it beneficial to still use singular thread objects for a specific task. I'm wondering in terms of a server in Java, whether or not the thread which is listening for connections, should share its resources with any other t

Java game: ArrayList and Iterator vs. thread

Sup guys. I'm writing a simple zombie game for my Java classes and I'm struck with a little problem: the Zombies are a class I made and I'm treating them on an ArrayList, like this: horda.add(new Zumbi( (int)(Math.random()* 750), 0)); Where the argum

Are unordered Boost containers safe for reading?

For example, for MSVC, read-only is thread-safe on containers. Is boost similarly thread-safe for read-only? Update: i.e. Can we expect `const' methods to guarantee no memory corruption for multi-threaded use.The upcoming standard defines the thread

Reactivity of the Android Dump sensor

I have an application in Android that dumps the sensor values to the SDcard memory of the phone and kills itself when I press a button on the screen. I am using Sensor_delay_fastest to get maximum update of the sensors. My problem is that since I'm d

Android service and thread

Is a "Service" in android same as a separate thread ?From Service javadoc: Note that services, like other application objects, run in the main thread of their hosting process. So the answer is No.

how to synchronize mysql database queries?

I have a lot of entries in a table that are fetched for performing jobs. this is scaled to several servers. when a server fetches a bunch of rows to add to its own job queue they should be "locked" so that no other server fetches them. when the

TPL Tasks, Threads, etc.

Could someone clear up to me how these things correlate: Task Thread ThreadPool's thread Paraller.For/ForEach/Invoke I.e. when I create a Task and run it, where does it get a thread to execute on? And when I call Parallel.* what is really going on un

Periodically iterating on a constantly changing collection

I have a collection of objects that's constantly changing, and I want to display some information about the contents every so often (my application is multi-threaded, and differently threads are constantly submitting requests to modify an object in t

Multithreaded Windows Service in MingW

I am trying to build a Windows service with MingW. It need thread safe exceptions, so I added the linker flag -mthreads. The application works fine from the command-line, but when I try to start it from services.msc, the 1054 error ("The service did

Java synchronized problem

I'm having issues with Synchronized not behaving the way i expect, i tried using volatile keyword also: Shared Object: public class ThreadValue { private String caller; private String value; public ThreadValue( String caller, String value ) { this.va