473,586 Members | 2,870 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(userLoca tion);
int g = p2[i].getGPSID();
t.Start(g);
}

}

public static void userLocation(ob ject 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 3282
veljkoz
3 New Member
If you're just starting with multithreading I suggest that you use the BackgroundWorke r - 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:

myBackgroundWor ker.RunWorkerAs ync(myArguments );
...

private void myBackgroundWor ker_DoWork(obje ct 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 RunWorkerComple ted. This event is raised when the DoWork event handler returns. (more info: msdn help on RunWorkerComple ted
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 backgroundWorke r
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
2226
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 doing this, but I don't seem to be able to get them to work. I was wondering if anybody can tell me what I am doing wrong. int rows = 10 ; int cols...
1
1907
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
11263
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 *)&multi);
13
3241
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 includes. My question is, if you must declare each method (as opposed to simply 'using' those methods like an #included file), then why not just declare...
28
2070
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 to handle exceptions. Say forexample I have a requirement where certain value has to be between 30-72 only and Iam doing this validation in the the...
0
1934
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 create SOAP client like this: public class StockService : SoapHttpClientProtocol {
1
1333
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 I have written so far, together with an increase in complexity and all the bad things that follow from that. Before I go ahead and make the...
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 thread running at any given moment. Typically, timers will have an interval of 5 to 15 minutes. Conditionally, the interval may be set to 1 second...
13
2057
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 back-end database, and with Access 97, if you added relationships, it would add multiple copies of the same relationships over and over, so I decided not...
14
2110
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 couldn't compile the class. Any hints that I'm missing? Header File: #ifndef __Calc_h__
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2345
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 we have to send another system
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.