Hi,
I called a function of a class from a form like:
In the class myController, I have the following code:
i.e. I am trying to start a thread from this function backupproc that I called from the form.
In DoBackup(), I have to do the following:
This I can do if I do not call a seperate class, but keep the code on the same form which makes it too busy.
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:
this here gives me an error 'method required'. Kindly advise what needs to be done.
I called a function of a class from a form like:
Code:
myController.BackupProc(myHandle);
Code:
public virtual void BackupProc(IntPtr thisHandle)
{
mBackgroundThread = new Thread(new ThreadStart(DoBackup));
mBackgroundThread.Start();
}
In DoBackup(), I have to do the following:
Code:
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:
Code:
myController.BackupProc(myHandle, this);
public virtual void BackupProc(IntPtr thisHandle, Form1 thisForm)
{
mBackgroundThread = new Thread(new ParameterizedThreadStart(DoBackup(thisForm)));
mBackgroundThread.Start();
}
Comment