3

I'm trying to implement a BackgroundWorker in .NET 1.1 (since there isn't any) and I'm not quite versed in threading and delegates.

Right now I have a class call BackgroundWorker with a method called DoWork. I know I must create a thread in the BackgroundWorker and execute a delegate in that thread, but there are two things I don't have quite clear yet.

  1. How can I start the thread in BackgroundWorker if DoWork receives a parameterless delegate? Or should I use another approach other than the delegate?

  2. How can I implement the ProgressChanged event?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
PedroC88
  • 3,708
  • 7
  • 43
  • 77
  • 2
    Is it *really* not an option to upgrade to .NET 2.0 (where `BackgroundWorker` *does* exist)? .NET 2.0 is supported on every platform that 1.1 is, as far as I'm aware, so you're not losing anything. – Cody Gray - on strike Dec 27 '11 at 15:18
  • Nop, is not (as much as I've tried). – PedroC88 Dec 27 '11 at 15:20
  • Don't make it an option to not upgrade, if they want the feature, then the upgrade must happen. – cadrell0 Dec 27 '11 at 16:08
  • They couldn't care less for the BackgroundWorker itself, it's me who understand it's the best option and although not the simplest to code, it may be easier to maintain the consuming code, rather than implementing threads all over. – PedroC88 Dec 27 '11 at 16:25

1 Answers1

3

Already done by Juval for 1.1

http://www.code-magazine.com/articleprint.aspx?quickid=0403071&printmode=true

rene
  • 41,474
  • 78
  • 114
  • 152
  • I've been reading up on this and I don't seem to find the declaration nor implementation on the `DoWorkEventArgs` class which isn't part of .NET-1.1 either. – PedroC88 Dec 28 '11 at 12:44
  • 1
    It is in the article. public class DoWorkEventArgs : CancleEventArgs { public bool Result{get;set;} public readonly object Argument; } – rene Dec 28 '11 at 15:08