public static void InitData() { ThreadScan santhread = new ThreadScan(); Application.Current.Properties["ScanDevice"] = santhread; string username=(string)Application.Current.Properties["UserName"]; new InitMonDevice(username); }
private void Application_Startup(object sender, StartupEventArgs e) { //设置用户名 string userID = "user001"; Application.Current.Properties["userID"] = userID; bus.DataBusServiceClient dataBusServiceClient=null; try { dataBusServiceClient=new bus.DataBusServiceClient(); //初始化设备类型集合 Application.Current.Properties["DeviceTypeArray"]=dataBusServiceClient.QueryAllDeviceTypeInfo(); //初始化设备集合 DataBus dataBus = new DataBus(); dataBus.fillDataBusByRemoteService(dataBusServiceClient,userID); Application.Current.Properties["DataBus"] = dataBus; } catch (Exception e1) { MessageBox.Show(e1.Message); } finally { if (dataBusServiceClient != null) dataBusServiceClient.Close(); dataBusServiceClient=null; } //////////////////////////////////////////////////// try { ThreadScan santhread = new ThreadScan(); Application.Current.Properties["ScanDevice"] = santhread; new InitMonDevice(userID); } catch (Exception e1) { throw e1; } }