BackgroundWorker vs. Asynch delegate method and BeginInvoke thread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?RWl0YW4=?=

    #1

    BackgroundWorker vs. Asynch delegate method and BeginInvoke thread

    Hello,

    I need to create a background thread and two (or more) options are available
    to me:

    1. BackgroundWorke r
    2. Asynch delegate method and BeginInvoke

    What are the differences between them in performance, complexity etc.

    Thanks,
    EitanB

  • Carl Daniel [VC++ MVP]

    #2
    Re: BackgroundWorke r vs. Asynch delegate method and BeginInvoke thread

    Eitan wrote:
    Hello,
    >
    I need to create a background thread and two (or more) options are
    available to me:
    >
    1. BackgroundWorke r
    2. Asynch delegate method and BeginInvoke
    >
    What are the differences between them in performance, complexity etc.
    BackgroundWorke r is easier. Unless you have some specific reason to not use
    it, that's probably your best choice.

    Async delegate uses the thread pool just as BackgroundWorke r does, but it's
    harder to use, will have no difference in performance, and is more complex.

    -cd


    Comment

    • =?Utf-8?B?RWl0YW4=?=

      #3
      Re: BackgroundWorke r vs. Asynch delegate method and BeginInvoke th

      Carl, Tanks
      EitanB

      "Carl Daniel [VC++ MVP]" wrote:
      Eitan wrote:
      Hello,

      I need to create a background thread and two (or more) options are
      available to me:

      1. BackgroundWorke r
      2. Asynch delegate method and BeginInvoke

      What are the differences between them in performance, complexity etc.
      >
      BackgroundWorke r is easier. Unless you have some specific reason to not use
      it, that's probably your best choice.
      >
      Async delegate uses the thread pool just as BackgroundWorke r does, but it's
      harder to use, will have no difference in performance, and is more complex.
      >
      -cd
      >
      >
      >

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: BackgroundWorke r vs. Asynch delegate method and BeginInvoke thread

        I disagree. If you want to just execute an action, without cancelling
        or notification while that action is performing on another thread, then I
        would say using an asynchronous delegate call, the Thread class, or the
        ThreadPool is much easer than the BackgroundWorke r class.

        If you need updates from the background thread, and/or the ability to
        cancel, then the BackgroundWorke r is the best option.


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

        "Carl Daniel [VC++ MVP]" <cpdaniel_remov e_this_and_nosp am@mvps.org.nos pam>
        wrote in message news:Oh10dEcCIH A.5752@TK2MSFTN GP02.phx.gbl...
        Eitan wrote:
        >Hello,
        >>
        >I need to create a background thread and two (or more) options are
        >available to me:
        >>
        > 1. BackgroundWorke r
        > 2. Asynch delegate method and BeginInvoke
        >>
        >What are the differences between them in performance, complexity etc.
        >
        BackgroundWorke r is easier. Unless you have some specific reason to not
        use it, that's probably your best choice.
        >
        Async delegate uses the thread pool just as BackgroundWorke r does, but
        it's harder to use, will have no difference in performance, and is more
        complex.
        >
        -cd
        >
        >

        Comment

        • =?Utf-8?B?RWl0YW4=?=

          #5
          Re: BackgroundWorke r vs. Asynch delegate method and BeginInvoke th

          Hello,

          Thanks for your anser.

          My thead will communicate (send command/recieve status) through the
          Ethernet. The status is a byte array, which I need to display on the screen.

          EitanB

          "Nicholas Paldino [.NET/C# MVP]" wrote:
          I disagree. If you want to just execute an action, without cancelling
          or notification while that action is performing on another thread, then I
          would say using an asynchronous delegate call, the Thread class, or the
          ThreadPool is much easer than the BackgroundWorke r class.
          >
          If you need updates from the background thread, and/or the ability to
          cancel, then the BackgroundWorke r is the best option.
          >
          >
          --
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard. caspershouse.co m
          >
          "Carl Daniel [VC++ MVP]" <cpdaniel_remov e_this_and_nosp am@mvps.org.nos pam>
          wrote in message news:Oh10dEcCIH A.5752@TK2MSFTN GP02.phx.gbl...
          Eitan wrote:
          Hello,
          >
          I need to create a background thread and two (or more) options are
          available to me:
          >
          1. BackgroundWorke r
          2. Asynch delegate method and BeginInvoke
          >
          What are the differences between them in performance, complexity etc.
          BackgroundWorke r is easier. Unless you have some specific reason to not
          use it, that's probably your best choice.

          Async delegate uses the thread pool just as BackgroundWorke r does, but
          it's harder to use, will have no difference in performance, and is more
          complex.

          -cd
          >

          Comment

          • Carl Daniel [VC++ MVP]

            #6
            Re: BackgroundWorke r vs. Asynch delegate method and BeginInvoke thread

            Nicholas Paldino [.NET/C# MVP] wrote:
            I disagree. If you want to just execute an action, without
            cancelling or notification while that action is performing on another
            thread, then I would say using an asynchronous delegate call, the
            Thread class, or the ThreadPool is much easer than the
            BackgroundWorke r class.
            Then you agree. In the case you describe, you have a specific reason not to
            use BackgroundWorke r - your use case does not fit well with the
            BackgroundWorke r model.

            -cd


            Comment

            Working...