Hello,
I am new to C#. I want to know one thing. How can I get value from text box(or update text box value from another thread) while working on C# Threading. I tried but cant able to get. Below is the code. I want to use text box values in public void Run() function as for unlimited value and then further use in private void AddString(String s) for showing as GUI.
private void AddString(String s)
{
n = hi.Text;
int val = Convert.ToInt32(m);
int val2 = Convert.ToInt32(s);
int val3 = Convert.ToInt32(n);
int sum = 0;
sum = sum + val3 + val2;
listBox1.Items.Add(sum);
}
public void Run()
{ String s;
int a = 2;
s=a.ToString();
while (true)
{
Thread.Sleep(400);
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { s });
// check if thread is cancelled
if (m_EventStop.WaitOne(0, true))
{ // clean-up operations may be placed here
// inform main thread that this thread stopped
m_EventStopped.Set();
return;
}
}
}
Hope to hear soon.
Regards.
Nasir