Hello,
I am trying to make a screen in visual studio 2010 with a few textboxes.
I want to make the text in the textboxes switch a few times when you hit a button.
So for example:
"textbox1" with text "123"
"textbox2" with text "456"
and when you hit the button 123 goes in textbox2 and 456 goes in textbox1
and this a thousand times or so. But at this moment it does the job but the user can't see it.
I read on forums I have to use threading to let the textboxes switch text and in the button I can do a refresh of the screen.
But my problem is when I use threading I need to make my method to let the textboxes switch static.
And when I do this the compiler gives me an error because when I use textbox1.Text = "..." the textbox1 isn't static so I can't use it this way.
How can I solve this problem?
Thanks in advance.
Loading
Sam HobbsPosted Dec 12, 2010, 1:07 AM
TomPosted Dec 11, 2010, 2:16 PM
In the meanwhile I found my answer in the video in following link:
http://windowsclient.net/learn/video.aspx?v=57027
In a short explanation I had to use delegate in my thread like this:
new Thread(
delegate()
{
Pl(l1, t1);
}
).Start();
And to interact between the 2 threads I had to use the following:
Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { textBox16.Text = text; }, null);
And this works fine for me.