public void RefreshData() { string tempLogString; comMMFViewAccessor = comMMF.CreateViewAccessor(0, capacity); //循环写入,使在这个进程中可以向共享内存中写入不同的字符串值 int strLength ; char[] charsInMMf; while (DetectMainProgram()) { SyncNamed.WaitOne(); strLength = comMMFViewAccessor.ReadInt32(0); charsInMMf = new char[strLength]; //读取字符 comMMFViewAccessor.ReadArray<char>(4, charsInMMf, 0, strLength); //------------------------------释放同步对象 SyncNamed.ReleaseMutex(); //------------------------------ stringInMMf=new string(charsInMMf); CustomFunc = XmlSerialize.DeserializeXML<List<CustomFunc>>(stringInMMf); //----------------------------------------------------- //----------------------------------------------------- foreach (CustomFunc m_CustomFunc in CustomFunc) { m_CustomFunc.a_ifuncDriver = allPlugins.Find(it => it.Info== m_CustomFunc.a_funcInfo.a_funcValue.driverName); if (m_CustomFunc.a_ifuncDriver != null) { } else { m_CustomFunc.a_funcInfo.a_stateValue.runState = "End"; m_CustomFunc.a_funcInfo.fault = "cant find driver file"; //---------------------------------------------------------------- tempLogString = "comName:" + m_CustomFunc.a_funcInfo.a_funcValue.funcName + "-找不到驱动文件-" + m_CustomFunc.a_funcInfo.a_funcValue.driverName; LogHelper.WriteLog(tempLogString); //---------------------------------------------------------------- #if DEBUG Debug.WriteLine("cant find driver file"); #endif } } //----------------------------------------------------- //----------------------------------------------------- //----------------------------------------- if (CustomFunc != null) { #if DEBUG Debug.WriteLine(CustomFunc[0].a_funcItfaceInfo.recData); #endif MethodInvoker In = new MethodInvoker(XmlDataGetted); this.BeginInvoke(In); MethodInvoker In2 = new MethodInvoker(TreeViewRefresh); this.BeginInvoke(In2); } else { LogHelper.WriteLog("共享内存读取错误"); } Thread.Sleep(new TimeSpan(0, 0, 0, 0, 1000)); } System.Environment.Exit(1); }