473,509 Members | 3,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question in c# multi-threading

29 New Member
Hi all;

I hope u don't ignore my question this time because whenever I ask questions
here nobody answer them T_T. what's the problem is they are too trivial in away
you don’t even want to answer them?? I really don’t know O_o

Anyway this is my problem;

i have a method which generate the user location;

and i wanna use multi threading to get the position of the user concurrently;

Hashtable ht = new Hashtable();

public void XYZ(List<User> p2)
{
for (int i = 0; i < p2.Count();i++ )
{
Thread t = new Thread(userLocation);
int g = p2[i].getGPSID();
t.Start(g);
}

}

public static void userLocation(object gpsid)
{

// generate the position x and y
ht.Add(gpsid, new Location(x, y));

}

i have read a tutorial about multithreading however am not sure if this is the right
way so that all the new created thread will work concurrently

thanks a lot;
Feb 22 '08 #1
2 3276
veljkoz
3 New Member
If you're just starting with multithreading I suggest that you use the BackgroundWorker - it's simple to understand and easily implemented. You have it in your toolbox/components.
Implement the DoWork event for it. You can pass arguments you need for it to work like this:

myBackgroundWorker.RunWorkerAsync(myArguments);
...

private void myBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
//here you can cast e.Argument to the type of myArguments and work with it.
}

If you need to do something upon the completion implement the RunWorkerCompleted. This event is raised when the DoWork event handler returns. (more info: msdn help on RunWorkerCompleted
Feb 22 '08 #2
RiskyHunter
29 New Member
veljkoz thanks 4 ur reply;

however, i really wanna knew whats the different (in term of functionalities) between
the two ways, the way that i implement the thread and the backgroundWorker
which way is much better;

thanks a lot;
Feb 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2218
by: Adam Hartshorne | last post by:
The input to a function of a 3rd party library I want to use requires a double**, which is a multi-dimension array of doubles. I have looked on the net etc and seen several ways of supposedly...
1
1904
by: herrcho | last post by:
#include <stdio.h> int multi; int main() { printf("\nmulti = %u",multi); printf("\nmulti = %u",multi); printf("\n&multi = %u\n",&multi); return 0;
2
11256
by: herrcho | last post by:
#include <stdio.h> int multi; int main() { printf("\nmulti = %p",(void *)multi); printf("\nmulti = %p",(void *)&multi); printf("\nmulti = %p",(void *)multi); printf("\n&multi = %p\n",(void...
13
3220
by: John Salerno | last post by:
Hi all. I have a question about interfaces now. According to the book I'm reading, when you implement an interface, the class or structure has to declare all the methods that the interface...
28
2062
by: jakk | last post by:
Hello All, I have a question about how to handle exceptions. Iam working on an ASP.NET application which has a presentation layer, Business Layer and DataAccess Layer. Iam confused about where...
0
1918
by: Kaimar Seljamäe | last post by:
Hi, I have to create a web service client which uses SOAP encoding but does not use "multi-reference" values (see http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383513 item 10). If I...
1
1332
by: Frank Millman | last post by:
Hi all I am developing a multi-user business/accounting application. It is coming along nicely :-), though rather slowly :-( I have hit an issue which will require a lot of changes to the code...
5
606
by: Tom | last post by:
Using multiple System.Timers.Timer objects in a Windows Service for performing multi-thread activities in a periodic fashion. Timers are AutoReset=false, to only have a single timer execution...
13
2039
by: ARC | last post by:
Hello all, Prior to going live with my app, I have questions on relationships theory. My prior app was done in Access 97, and I did NOT use relationships at all. I have 65 tables in my...
14
2103
by: Alexander Dong Back Kim | last post by:
Dear all, I used to use C++ programming language at all time but moved to C# and Java. Few days ago, I restarted studying about C++ with a very beginner's mind. I wrote a simple class and gcc...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.