There is an issue: when Agentry action triggered from OpenUI, it is not executed and cause AG client crash under certain scenario.
The OpenUI is defined at MainMenuScreen: spawn a background thread to monitoring a folder for new file creation, if certain file e.g. 12345678.nav is found created in that folder, then OpenUI calls Agentry action to navigate to the Work Order list screen and do list selection of WO 12345678.
1. If the Agentry Screen is at MainMenu, BUT the Windows OS focus (active window) is at other process say notepad.exe, then the Navigation step never occurs and cause AG client crash
2. If the Agentry Screen is at MainMenu, AND the Windows OS focus is at Agentry process, then the Navigation step occurs and proper WO is selected afterwards
3. If the Agentry Screen is already at Work Order list screen, it does not matter who has the Windows OS focus, then proper WO is selected (here, Navigation seems to be ignored)
// Specify what is done when a file is created.
string[] files = Directory.GetFiles(navwodir, "*nav");
wo = Path.GetFileNameWithoutExtension(files[0]);
//if (System.IO.File.Exists(@"" + navwodir + wo + ".nav"))
//{
// System.IO.File.Delete(@"" + navwodir + wo + ".nav");
//}
if (Application.Current.Dispatcher.CheckAccess())
{
MessageBox.Show("Safe on Main");
CallAgentryAction(wo);
}
else
{
// bg thread
Application.Current.Dispatcher.BeginInvoke
(
new Action
(
() =>
{
CallAgentryAction(wo);
}
)
);
}
Message was edited by: jinlin wang The monitoring process uses STATIC BackgroundWorker. The worker_DoWork basically use FileSystemWatcher to monitor a folder. private static BackgroundWorker worker = null; if (worker == null) { worker = new BackgroundWorker(); //worker.WorkerReportsProgress = true; worker.DoWork += worker_DoWork; worker.WorkerSupportsCancellation = true; //worker.ProgressChanged += worker_ProgressChanged; worker.RunWorkerCompleted += worker_RunWorkerCompleted; if (worker.IsBusy != true) { worker.RunWorkerAsync(); } }