when I execute the following code in my wpf application. I get a System.InvalidOperationException
, as soon as the code trys to access textBoxResult.Text
. I assume it has something to do with scope. I am not that expierenced with c#. Could someone please explain what is the problem and how to do it right?
Code:
private void buttonRun_Click(object sender, RoutedEventArgs e)
{
var startTimeSpan = TimeSpan.Zero;
var periodTimeSpan = TimeSpan.FromSeconds(5);
var timer = new System.Threading.Timer((timer_e) =>
{
textBoxResult.Text = "";
device.Service.Inputs = textBoxRun.Text;
device.Service.Run(device.ResourceStore.Resources);
}, null, startTimeSpan, periodTimeSpan);
}