multithreading

Testing Code With Threads in .NET

I need to test my vigorously tested code works when called by many threads So I am calling the code in a loop in a TestMethod using TreadPool.QueueUserWorkItem however there does not seem to be anyway of holding the current thread while all the threads kicked off are still running. i.e. pretend code.... using Microsoft.VisualStudio.T...

SerialPort Buffer on New Thread

I have a MySerialPort class/object accessed from FormGUI. After creating a MySerialPort object, I want to open it, and keep receiving data continuously. The data will be stored and managed in the object's data buffer. FormGUI's memoEdit will show the received codes from the MySerialPort object's buffer. How can I use "new Thread()" with...

Strange behavior with a low thread priority.

I have 2 threads, one that decodes bitmaps from the assetManager, and another that is my SurfaceView. When i set the priority of the bitmap decoder very low, i actually get more lag then if its much higher. Why would it act like that? thanks. Heres my code: public void bitmapLoader(final String filePath,final int pathVariable) ...

Using xterm to open a new console: How to while the current console is printing, to print on the new console also.

I'm using python right now. I have a thread that represents my entire program. I want to open another console window using os.system(xterm&) as a thread which works. The only thing is, is it possible to print to the new window while the other thread is printing to the older window? import sys import os def my_fork(): child_pid ...

Thread.join blocks the main thread

Calling Thread.join blocks the current (main) thread. However not calling join results in all spawned threads to be killed when the main thread exits. How does one spawn persistent children threads in Ruby without blocking the main thread? Here's a typical use of join. for i in 1..100 do puts "Creating thread #{i}" t = Thread.new(i...

What's the principle of blocking mode?

Like blocks until the file is done playing, what's the principle and how to implement this? ...

Need some feedback on how to make a class "thread-safe".

I'm currently learning how to do multithreading in C++. One of my learning projects is a Tetris game. In this project I have a Game class that contains all game state data. It has methods for moving the block around and a few other things. This object will be accessed by the user (who will use the arrow keys to move the block, from the m...

Add items to a table from a thread in asp.net

I have a HTML table which I add items to from javascript on an ASP.NET callback when a button is clicked. HTML: <%@ Page Language="C#" CodeFile="Hello5.aspx.cs" Inherits="ClientCallback" %> <html> <head> <script> function AddResult() { GetResults("blah", ""); } function UpdateTable(itemText) { var ...

How to access a non-static method from a thread in C#

Hello there, I'm not sure if this is good programming etiquette, anyway I have a normal method in which I update certain bits of data and UI elements such as textblocks etc. Anyway, I want to create a thread that every X amount of Seconds it runs the Update Method but I cannot access it because from what I understand a thread can only ...

How can a new Form be run on a different thread in C#?

I'm just trying to run a new thread each time a button click even occurs which should create a new form. I tried this in the button click event in the MainForm: private void button1_Click(object sender, EventArgs e) { worker1 = new Thread(new ThreadStart(thread1)); worker2 = new Thread(new ThreadStart(thread2)); worker1.S...

Is it possible to list mutexs which a thread holds

Firstly, I use pthread library to write multithreading c program. Threads always hung by their waited mutexs. When I use the strace utility to find a thread is in FUTEX_WAIT status, I want to know which thread hold that mutex at the time. But I don't know how could I make it. Are there any utilities could do that? Someone told me java v...

Use threads during iteration

There is a collection and each element of that collection is sent to a function where 5 threads have to work on it. How to make 5 threads work on the passed item? foreach(var item in collection) { doSomeWork(item); } void doSomeWork(object item) { //here i have to do something with the passed 'item' by using 5 threads } ...

How do I pass information from a ThreadPool.QueueUserWorkItem back to the UI thread?

I have a rather simple threading question. I'm writing a simple utility that will run various SQL scripts based on parameters defined by the user. In order to keep the UI responsive and provide feedback as to the status of the scripts that are being executed, I've decided that using ThreadPool.QueueUserWorkItem would be appropriate to ...

signaling a sleeping thread

I'm new to multithreading in c# and am confused among all thread stuff. here is what I'm trying to have: public class TheClass { Thread _thread; bool _isQuitting; bool _isFinished; object jobData; public void Start() { jobData = new object(); _thread = new Thread(new ThreadStart(Run)); _th...

Hooking and controlling a background process's input events

Hi, I'm currently researching ways to hook a process and take control of it using mouse/keyboard events whilst it is in the background (Ala, not the active window). I guess you could think of it as a more advanced macro that doesn't require the targeted window/process to be active. Now I know the process hooking code is abundantly well...

c++ member array of struct thread safe using only one index per thread ?

is a c++ member array of struct thread safe using only one index per thread ? using the following class: typedef struct { bool bFlag; unsigned int uiNum; } TC_MYSTRUCT; class MyClass { public: MyClass(); ~MyClass(); int GetFreeIndex(); void SetIndexDataNum(int idx, int num); int GetIndexDataNum(int idx); pr...

use parametric function in thread in C#

hi this is my multi thread codes it works fine using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; using System.Threading; namespace searchIpAdresses { public partial class frmSearchI...

asynchronous Inter thread communication

Hi, I'm making a cross plateform program that embbed a small RARP server (implemented with winpcap/pcap) and runs 2 TCP IP servers. I have to use C++. So i will have at least 4 threads, the main one wich countain the controller, 2 TCP/IP async socket, and the RARP server. I planned to use c++ BOOST Asio and Thread, because i need to r...

python program bug help

I've got an exam coming up soon. I've been looking through the past paper, this question keeps bugging me. I can't seem to find what the bug in the program could be because I'm quite new to all this. Can anyone help me out? The following program contains a bug. Determine what kind of problem the program exhibits, and show how it can be...

C# Is a Parallel foreach while loop possible?

I'm not sure how the internal thread handling of Parallel.foreach works and whether it can guarantee that a construct like this would work? Parallel.Foreach(Connections, c => { Input in = c.getInput(); while (in.hasNext()) { object o = in.getNext(); dosomething(o); } } ); where i...