469,963 Members | 1,675 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

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;idx++)
{
ClassB ob=new ClassB();
ThreadPool.QueueUserWorkItem(new WaitCallback(ob.Exec));
}

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

TIA
Nov 16 '05 #1
5 1298
Vai2000,

There is an article in MSDN magazine this month that will help you out
here. It is the .NET Matters section, titled "ThreadPoolWait and
HandleLeakTracker" 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.com

"Vai2000" <no****@microsoft.com> wrote in message
news:O0****************@TK2MSFTNGP11.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;idx++)
{
ClassB ob=new ClassB();
ThreadPool.QueueUserWorkItem(new 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.com> wrote in
message news:eH**************@TK2MSFTNGP10.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 "ThreadPoolWait and
HandleLeakTracker" 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.com

"Vai2000" <no****@microsoft.com> wrote in message
news:O0****************@TK2MSFTNGP11.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;idx++)
{
ClassB ob=new ClassB();
ThreadPool.QueueUserWorkItem(new 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\datatypes 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.ExecuterReader(connString,"GetMonitoredR ows_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..com> wrote in message
news:eB**************@TK2MSFTNGP09.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\datatypes 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.ExecuterReader(connString,"GetMonitoredR ows_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..com> wrote in message
news:eB**************@TK2MSFTNGP09.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 ConvertBytesToString(byte[] b)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();

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

i.e.

string str = ConvertBytesToString(_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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

65 posts views Thread by Anthony_Barker | last post: by
2 posts views Thread by Egor Bolonev | last post: by
6 posts views Thread by CK | last post: by
2 posts views Thread by Vjay77 | last post: by
11 posts views Thread by Paul Sijben | last post: by
reply views Thread by kingcrowbar.list | last post: by
2 posts views Thread by Daniel | last post: by
7 posts views Thread by Mike P | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.