473,574 Members | 2,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threading Scneario!

Hi All, I have a ClassA and a worker ClassB.
in my ClassA I have a method which calls the following routine
for(int idx=0;idx<10;id x++)
{
ClassB ob=new ClassB();
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(ob .Exec));
}

I want to know/signal when all the Worker ClassB are done?

TIA
Nov 16 '05 #1
5 1421
Vai2000,

There is an article in MSDN magazine this month that will help you out
here. It is the .NET Matters section, titled "ThreadPool Wait and
HandleLeakTrack er" and you can find it at (watch for line wrap):

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

It's the first question in the section.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:O0******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi All, I have a ClassA and a worker ClassB.
in my ClassA I have a method which calls the following routine
for(int idx=0;idx<10;id x++)
{
ClassB ob=new ClassB();
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(ob .Exec));
}

I want to know/signal when all the Worker ClassB are done?

TIA

Nov 16 '05 #2
Thanks my friend

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:eH******** ******@TK2MSFTN GP10.phx.gbl...
Vai2000,

There is an article in MSDN magazine this month that will help you out
here. It is the .NET Matters section, titled "ThreadPool Wait and
HandleLeakTrack er" and you can find it at (watch for line wrap):

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

It's the first question in the section.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:O0******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi All, I have a ClassA and a worker ClassB.
in my ClassA I have a method which calls the following routine
for(int idx=0;idx<10;id x++)
{
ClassB ob=new ClassB();
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(ob .Exec));
}

I want to know/signal when all the Worker ClassB are done?

TIA


Nov 16 '05 #3
Hello everyone,
I am building a service that stores table rows in a collection.

The service will ocasionally "refresh" it's collection with the rows that
have changed since the last "refresh"

I am trying to us the SQL timestamp (equivalent to a binary(8) column) to
determine which rows have changed:
So I want to:
Save the timestamp
Query for records that have a timestamp greater than the saved timestamp
Save the greatest timestamp

I don't seem to understand how to get the conversions\dat atypes correct:

//I want to start off at zero:
byte[] _timeStamp= {0x00000000};

//Use SQLHelper from Data Access Application Block
//This works as long as _timeStamp is byte[]
SqlDataReader dr =
SqlHelper.Execu terReader(connS tring,"GetMonit oredRows_sp", _timeStamp);

//I have tried byte and byte[].
byte[] _tempTS;
while (dr.Read())
{
Nov 16 '05 #4
Take a look at BINARY_CHECKSUM in BOL....

"Next" <ae************ ******@cafsmail .no*jg^_junk..c om> wrote in message
news:eB******** ******@TK2MSFTN GP09.phx.gbl...
Hello everyone,
I am building a service that stores table rows in a collection.

The service will ocasionally "refresh" it's collection with the rows that
have changed since the last "refresh"

I am trying to us the SQL timestamp (equivalent to a binary(8) column) to
determine which rows have changed:
So I want to:
Save the timestamp
Query for records that have a timestamp greater than the saved timestamp
Save the greatest timestamp

I don't seem to understand how to get the conversions\dat atypes correct:

//I want to start off at zero:
byte[] _timeStamp= {0x00000000};

//Use SQLHelper from Data Access Application Block
//This works as long as _timeStamp is byte[]
SqlDataReader dr =
SqlHelper.Execu terReader(connS tring,"GetMonit oredRows_sp", _timeStamp);

//I have tried byte and byte[].
byte[] _tempTS;
while (dr.Read())
{
.
.
.
//Tried several conversions here. This doesn't work because
//it doesn't return a byte[]
_tempTS = Convert.ToByte( dr["timestamp"].ToString());

//Can't compare strings; Can't compare byte[]. How should
//I make this comparison
if( _tempTS > _timeStamp)
{
_timeStamp = _tempTS;
}

}

Any help would GREATLY ;) be appreciated.

Thanks in advance!
Aaron

Nov 16 '05 #5

"Next" <ae************ ******@cafsmail .no*jg^_junk..c om> wrote in message
news:eB******** ******@TK2MSFTN GP09.phx.gbl...
//I have tried byte and byte[].
byte[] _tempTS;
while (dr.Read())
{
.
.
.
//Tried several conversions here. This doesn't work because
//it doesn't return a byte[]
_tempTS = Convert.ToByte( dr["timestamp"].ToString());

//Can't compare strings; Can't compare byte[]. How should
//I make this comparison
if( _tempTS > _timeStamp)
{
_timeStamp = _tempTS;
}

Try this :

byte[] _tempTS; // stick with a byte array.
....
_tempTS = (byte[]) dr["timestamp"];
// timestamp columns should be of type : byte[], so the cast should work.

To make the comparison, you'll have to compare the byte array one byte
at a time. If you want a human readable string representation of the
byte array, you could use a routine like this :

private string ConvertBytesToS tring(byte[] b)
{
System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();

sb.Append("0x") ;
for (int i = 0; i < b.Length; i++)
{
sb.Append(b[i].ToString("X2") );
}
return sb.ToString();
}

i.e.

string str = ConvertBytesToS tring(_tempTS);

If this doesn't help, try the dotnet adonet newsgroup -
they'll probably be of more help.

HTH,
Stephen
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
6695
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace,...
2
2961
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def get_all_files(path): """return all files of folder path, scan with subfolders
77
5232
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for the moment. I'd be *very* grateful if people with any interest in multi-threading would read it (even just bits of it - it's somewhat long to go...
6
555
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service and the final process(3) gets called. what am I doing wrong with the threading? by the way Directory.GetFiles(IncomingXMLPath1).Length is some...
2
2238
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True Me.bytesDownloadedTextBox.Text = "" Me.totalBytesTextBox.Text = ""
11
5004
by: Paul Sijben | last post by:
I am stumped by the following problem. I have a large multi-threaded server accepting communications on one UDP port (chosen for its supposed speed). I have been profiling the code and found that the UDP communication is my biggest drain on performance! Communication where the client and the server are on the same machine still takes 300ms...
17
6399
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. Note, the Windows task manager shows 2 CPUs on the Performance tab with hyper-threading is turned on. Both Python 2.3.5 and 2.4.3 (downloaded from...
0
1576
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first version i made, the gui would freeze after clicking the close button until pygame finished playing the sound. In Windows it was acceptable because it...
2
5279
by: Daniel | last post by:
I have a class similar to this: class MyThread(threading.Thread): def __init__(self): self.terminated = False def run(self): while not self.terminated:
7
2363
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has finished. I am trying to follow this example : http://www.codeproject.com/cs/miscctrl/progressdialog.asp But although the messages still get...
0
7805
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8053
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
8237
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...
0
6454
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5622
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
5301
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...
0
3741
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1060
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.