Threading using QueueUserWorkItem

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

    #1

    Threading using QueueUserWorkItem

    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.Threa dPool.QueueUser WorkItem(New Threading.WaitC allback(

    _
    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

  • Brian Gideon

    #2
    Re: Threading using QueueUserWorkIt em

    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.Threa dPool.QueueUser WorkItem(New Threading.WaitC allback(
    >
    _
    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

    Comment

    • Bharathi kumar

      #3
      Re: Threading using QueueUserWorkIt em

      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:
      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.Threa dPool.QueueUser WorkItem(New Threading.WaitC allback(

      _
      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

      Comment

      • Brian Gideon

        #4
        Re: Threading using QueueUserWorkIt em

        Bharathi,

        I'm glad you figured it out.

        Brian

        Bharathi kumar wrote:
        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.

        Comment

        Working...