Threads problems

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

    #1

    Threads problems


    Hello,
    I am trying to build thread inside thread in this way:

    Thread A (start)
    {
    successHandler = false
    commandA
    commandB
    Thread B (start)
    if (successHandler )
    commandC

    Handler B
    {
    successHandler = true
    }
    }
    Handler A
    {
    end
    }

    Somehow I got stucked after HandlerB and commandC is not activated. Why
    is that? Thank u!



    }


    *** Sent via Developersdex http://www.developersdex.com ***
  • Marc Gravell

    #2
    Re: Threads problems

    First - it is very hard to unpick your intentions from that pseudo-code.
    Some genuine (but slimmed down) code would be much more useful.

    It is highly unlikely what thread B has done much when you run the
    "successHandler " test. What is it you are actually trying to do? If you
    need to wait for thread B to get "so far" you will need a wait-handle of
    some kind (Monitor, AutoResetEvent, etc).

    But it also begs the question of whether thread A could do this bit,
    befoer starting thread B (no point it just sitting there...)

    Marc

    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: Threads problems

      On Apr 8, 8:53 am, csharpula csharp <csharp...@yaho o.comwrote:
      Hello,
      I am trying to build thread inside thread in this way:
      >
      Thread A (start)
      {
      successHandler = false
       commandA
       commandB
       Thread B (start)
       if (successHandler )
       commandC
      >
       Handler B
      {
      successHandler = true}
      }
      >
      Handler A
      {
      end
      >
      }
      >
      Somehow I got stucked after HandlerB and commandC is not activated. Why
      is that? Thank u!
      >
      }
      >
      *** Sent via Developersdexht tp://www.developersd ex.com***
      Hi,

      Are you sure you need a thread? (Handler B) ?
      From your code it seems that first thread should block until Thread B
      ends.
      What are you trying to do?

      Comment

      Working...