Ok - I've got this code
Running in a DispatcherTime
And if you look at the image I've attached - if the reader responds it nicely clears the .Text and Enables it and sets the Focus.
So Break #1 hits
If the reader does not respond - as I am showing in the image that is attached - the BREAK is actually at the circled spot. That's good.
But it never gets to Break #2 - never pops up the message box.
What am I doing wrong?
Code:
private void SendToReader(object sender, EventArgs ea) //(object objectState)
{
//long tc = System.Threading.Interlocked.Increment(ref TimerClick);
lock (mainTimer)
{
//mainTimer.Change(System.Threading.Timeout.Infinite, 250);
mainTimer.IsEnabled = false;
}
.
.
.
bool doContactReader = true;
while (doContactReader)
{
if (cl2.asyncPostText("sessionid", ref rdFSOb, prefixes, cqMS, ref returnMessage))
{
doContactReader = false;
SessionId = Convert.ToInt64(rdFSOb.FNTagsCollection[0]);
this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (System.Threading.ThreadStart)delegate()
{
txtSearch.Text = "";
txtSearch.IsEnabled = true;
txtSearch.Focus();
});
}
else
{
this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (System.Threading.ThreadStart)delegate()
{
if (MessageBox.Show("Reader is not responding - try again?", "Try Again or Cancel", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
{
doContactReader = false;
txtSearch.Text = "";
}
});
}
}
Code:
mainTimer = new DispatcherTimer(DispatcherPriority.Normal);
mainTimer.Interval = new TimeSpan(250);
mainTimer.Tick += new EventHandler(SendToReader);
mainTimer.IsEnabled = true;
So Break #1 hits
If the reader does not respond - as I am showing in the image that is attached - the BREAK is actually at the circled spot. That's good.
But it never gets to Break #2 - never pops up the message box.
What am I doing wrong?