I called a function of a class from a form like:
Expand|Select|Wrap|Line Numbers
- myController.BackupProc(myHandle);
Expand|Select|Wrap|Line Numbers
- public virtual void BackupProc(IntPtr thisHandle)
- {
- mBackgroundThread = new Thread(new ThreadStart(DoBackup));
- mBackgroundThread.Start();
- }
In DoBackup(), I have to do the following:
Expand|Select|Wrap|Line Numbers
- private void DoBackup()
- {
- this.invoke(new BackgroundThreadCB(HandleDeviceBusy));
- }
I want a way so that I can pass the 'this' instance of the form from the form to the class and through the thread.
The problem comes here when I want to pass the instance of the form through the thread.
I am trying to do something like:
Expand|Select|Wrap|Line Numbers
- myController.BackupProc(myHandle, this);
- public virtual void BackupProc(IntPtr thisHandle, Form1 thisForm)
- {
- mBackgroundThread = new Thread(new ParameterizedThreadStart(DoBackup(thisForm)));
- mBackgroundThread.Start();
- }