Threading Scneario!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vai2000

    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


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Threading Scneario!

    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):

    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


    It's the first question in the section.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Vai2000" <nospam@microso ft.com> wrote in message
    news:O0yqw%23An EHA.3868@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > 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
    >
    >[/color]


    Comment

    • Vai2000

      #3
      Re: Threading Scneario!

      Thanks my friend

      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:eHssZDBnEH A.3296@TK2MSFTN GP10.phx.gbl...[color=blue]
      > 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]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "Vai2000" <nospam@microso ft.com> wrote in message
      > news:O0yqw%23An EHA.3868@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > 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
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Next

        #4
        C# Byte[] and SQL timestamp

        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())
        {

        Comment

        • alien2_51

          #5
          Re: C# Byte[] and SQL timestamp

          Take a look at BINARY_CHECKSUM in BOL....



          "Next" <aeverettNO^ryz d_SPAM@cafsmail .no*jg^_junk..c om> wrote in message
          news:eBFMPdDnEH A.3908@TK2MSFTN GP09.phx.gbl...[color=blue]
          > 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
          >
          >[/color]


          Comment

          • Stephen Ahn

            #6
            Re: C# Byte[] and SQL timestamp


            "Next" <aeverettNO^ryz d_SPAM@cafsmail .no*jg^_junk..c om> wrote in message
            news:eBFMPdDnEH A.3908@TK2MSFTN GP09.phx.gbl...[color=blue]
            > //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;
            > }[/color]


            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


            Comment

            Working...