Home All Groups Group Topic Archive Search About

Threading using QueueUserWorkItem

Author
14 Sep 2006 6:38 AM
Bharathi kumar
Hi,

    Iam working in windows appln using .NET framework 2.0.


   My application is having several threads running.


   All threads can call a common method.


   I have following code in my common method.
     Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(

_
                                                AddressOf MyFunction))


   When I call the common method, its executing "MyFunction" twice.


  I want the "MyFunction" to execute only once.


Any suggestions please.


Regards,
Bharathi Kumar

Author
14 Sep 2006 3:42 PM
Brian Gideon
Bharathi,

That's certainly not what's suppose to happen.  I think you'll have to
provide a short, but complete program that demonstrates the problem.

Brian

Bharathi kumar wrote:
Show quoteHide quote
> Hi,
>
>     Iam working in windows appln using .NET framework 2.0.
>
>
>    My application is having several threads running.
>
>
>    All threads can call a common method.
>
>
>    I have following code in my common method.
>      Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(
>
> _
>                                                 AddressOf MyFunction))
>
>
>    When I call the common method, its executing "MyFunction" twice.
>
>
>   I want the "MyFunction" to execute only once.
>
>
> Any suggestions please.
>
>
> Regards,
> Bharathi Kumar
Author
15 Sep 2006 3:40 AM
Bharathi kumar
Hi,

    Iam sorry. Its working fine.

One of  my colleague had modified the code. They have added one more
thread thats calling "MyFunction".

So "MyFunction" had called twice.

I didn't notice that code and thought the behaviour was peculiar.

Thank you very much,
Regards,
Bharathi Kumar.


Brian Gideon wrote:
Show quoteHide quote
> Bharathi,
>
> That's certainly not what's suppose to happen.  I think you'll have to
> provide a short, but complete program that demonstrates the problem.
>
> Brian
>
> Bharathi kumar wrote:
> > Hi,
> >
> >     Iam working in windows appln using .NET framework 2.0.
> >
> >
> >    My application is having several threads running.
> >
> >
> >    All threads can call a common method.
> >
> >
> >    I have following code in my common method.
> >      Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(
> >
> > _
> >                                                 AddressOf MyFunction))
> >
> >
> >    When I call the common method, its executing "MyFunction" twice.
> >
> >
> >   I want the "MyFunction" to execute only once.
> >
> >
> > Any suggestions please.
> >
> >
> > Regards,
> > Bharathi Kumar
Author
15 Sep 2006 1:34 PM
Brian Gideon
Bharathi,

I'm glad you figured it out.

Brian

Bharathi kumar wrote:
Show quoteHide quote
> Hi,
>
>     Iam sorry. Its working fine.
>
> One of  my colleague had modified the code. They have added one more
> thread thats calling "MyFunction".
>
> So "MyFunction" had called twice.
>
> I didn't notice that code and thought the behaviour was peculiar.
>
> Thank you very much,
> Regards,
> Bharathi Kumar.