I apologize in advance if this is a stupid question. I am a C programmer by profession, and C # is relatively new.
I have an application that basically boils down to the following: one thread that checks the external interface (profibus in case someone is interested), when the input changes the event and new data is raised. Because the data I need to update uses data binding. I call the dispatcher. This setting works properly millions of times, but sometimes it takes up to 6 seconds before the code is executed in deletion. Since there are no other threads, I see no reason for this. I am using the following event handler. A container is a reference to a TabItem for which the class is bound to a database.
public void newSlave_InputChanged(object sender, InputChangedEventArgs e)
{
DateTime beforeDisp = DateTime.Now;
Container.Dispatcher.Invoke(DispatcherPriority.Send, (Action)delegate()
{
DateTime afterDisp = DateTime.Now;
if (afterDisp.Subtract(beforeDisp).TotalSeconds > 1)
{
}
}
);
}
:
void monitorSlaves()
{
while (true)
{
if (cardOnline)
{
foreach (slave slv in slaves)
{
if (dataChanged)
{
}
}
}
Console.WriteLine(string.Format("{0}: Monitor slaves", DateTime.Now));
}
Thread.Sleep(200);
}
}
, , , "". , . , , , . , 2010 , intellitrace .
.