I don't understand why you need to use MethodInvoke in order to call your
function (It seems you are trying a combination of threading and
reflection). You could use something like the next sample, where I am using
the member variable "someMessage" as a way of passing the string to the new
thread. Perhaps you will have to add some synchronization to the
someMessage variable.
public class MyClass
{
private string someMessage;
public void DoSomething()
{
//....
this.someMessage = "Some Message";
new Thread(new ThreadStart(this.MyThreadFunction())).Start();
}
public void MyThreadFunction()
{
DoSomething(this.someMessage);
}
}
You could also consider sending some notifications to update the
slider/message.
Sorry cut and pasted the wrong bit of code. (which obviously doesn't work)
It shoul have been
I've tried
MethodInvoker mi = new MethodInvoker(m_ProgressBar.UpdateDescription);
object[] args = {m_txtUpdateDescription.Text};
this.BeginInvoke(m_ProgressBar.UpdateDescription, args);
but the first line doesn't compile.
"rollasoc" <ho*****@hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl... Hi,
Having a slight problem with how to pass parameters to functions between
threads.
I have a form with a progress bar and a description label on it. It has
a public function
IncrementProgressBar() that just calls performstep on the progress bar.
On my main form I create a thread which creates the progress bar form
Then using
MethodInvoker mi = new MethodInvoker(m_ProgressBar.IncrementProgressBar);
this.BeginInvoke(mi);
I can get this function called wherever is appropriate.
All is fine. But I want a function that takes a string as a parameter so
I can dynamically update the description.
Any idea how to do this? I've searched google and found nothing so far.
I've tried
MethodInvoker mi = new MethodInvoker(m_ProgressBar.UpdateDescription);
object[] args = {m_txtUpdateDescription.Text};
this.BeginInvoke(m_ProgressBar.UpdateTitle, args);
but the first line doesn't compile.
Rollasoc
Adrian Vinca [MSFT], Developer Division
--------------------------------------------------------------------
This reply is provided "AS IS", without warranty (express or implied).
Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.