C# Programming
05-11-2011, 09:01 AM
Hi guys,
First of all - I am not very experienced. I have the following strage situation:
Task t = null;
t = Task.Factory.StartNew(() =>
{
while (true)
{
// do some calculations
LogToUi("some result");
Thread.Sleep(15000);
}
});
LogToUi is a function that updates a textbox in the UI. It does it pretty straightforward tbUpdateMe.Text = passedtoLogToUiText;
This works just fine, it also works if I use a listbox instead of textbox, but If I would like to change LogToUi to update a datagridview - it does not work.
I was told that in general what I have written should not work.... But it does... So why?
A friend of mine told me that even with textbox it should not work... But it does... So what is the situation and can I expect that it will work with TextBox but not very stable or what?
First of all - I am not very experienced. I have the following strage situation:
Task t = null;
t = Task.Factory.StartNew(() =>
{
while (true)
{
// do some calculations
LogToUi("some result");
Thread.Sleep(15000);
}
});
LogToUi is a function that updates a textbox in the UI. It does it pretty straightforward tbUpdateMe.Text = passedtoLogToUiText;
This works just fine, it also works if I use a listbox instead of textbox, but If I would like to change LogToUi to update a datagridview - it does not work.
I was told that in general what I have written should not work.... But it does... So why?
A friend of mine told me that even with textbox it should not work... But it does... So what is the situation and can I expect that it will work with TextBox but not very stable or what?