Пример #1
0
 public void WaitToStop()
 {
     System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(BeginShowMessage);
     System.Threading.Thread th = new System.Threading.Thread(start);
     th.IsBackground = true; //设置为后台线程,主线程关闭,随之关闭
     th.Start();             //开始线程
 }
Пример #2
0
        public static uint StartContext(string name, System.Threading.ParameterizedThreadStart entry, Context_Type type, object param)
        {
            Context context = new Context();

            context.type       = type;
            context.tid        = m_NextCID++;
            context.name       = name;
            context.stacktop   = GCImplementation.AllocNewObject(4096);
            context.esp        = (uint)SetupStack((uint *)(context.stacktop + 4000));
            context.state      = Thread_State.ALIVE;
            context.paramentry = entry;
            context.param      = param;
            if (type == Context_Type.PROCESS)
            {
                context.parent = 0;
            }
            else
            {
                context.parent = m_CurrentContext.tid;
            }
            Context ctx = m_ContextList;

            while (ctx.next != null)
            {
                ctx = ctx.next;
            }
            ctx.next = context;
            return(context.tid);
        }
Пример #3
0
        /// <summary>
        /// 自相交检查主程序
        /// </summary>
        /// <param name="_AppHk"></param>
        private void ExcuteSelfIntersectionCheck(Plugin.Application.IAppGISRef _AppHk)
        {
            #region 取得进度条对象
            Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef;
            //取得进度条对象
            try
            {
                //高亮显示处理结果栏
                DevComponents.DotNetBar.PanelDockContainer PanelTip = _AppHk.DataTree.Parent as DevComponents.DotNetBar.PanelDockContainer;
                PanelTip.DockContainerItem.Selected = true;

                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(Line_self);
                System.Threading.Thread thread = new System.Threading.Thread(start);
                _AppHk.CurrentThread = thread;//得到当前的进程
                thread.Start(pAppForm);
            }
            catch (Exception ex)
            {
                if (_AppHk.CurrentThread != null)
                {
                    _AppHk.CurrentThread = null;
                }

                MessageBox.Show(ex.ToString());
                return;
            }
            #endregion
        }
Пример #4
0
        public override void OnClick()
        {
            if (_AppHk == null)
            {
                return;
            }
            if (_AppHk.MapControl == null)
            {
                return;
            }

            //执行修正图形的处理
            Plugin.Application.IAppGISRef Apphook = _AppHk as Plugin.Application.IAppGISRef;

            try
            {
                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(ExcuteCorrect);
                System.Threading.Thread thread = new System.Threading.Thread(start);
                if (Apphook.DataCheckGrid.Rows.Count > 0)
                {
                    Apphook.DataCheckGrid.DataSource = null;//拓扑是不显示出错的,直接修正0或没用的要素
                }
                Apphook.CurrentThread = thread;
                thread.Start(_AppHk as object);
            }
            catch (Exception ex)
            {
                if (Apphook.CurrentThread != null)
                {
                    Apphook.CurrentThread = null;
                }
                MessageBoxEx.Show(ex.ToString());
                return;
            }
        }
Пример #5
0
    /// <summary>
    /// 异步释放www
    /// </summary>
    /// <param name="www"></param>
    public static void DisposeAsync(this WWW www)
    {
        if (www == null)
        {
            return;
        }

        System.Threading.ParameterizedThreadStart dispose = w => {
            try
            {
                if (w is WWW)
                {
                    ((WWW)w).Dispose();//www的dispose 方法 比较耗时,在协程中释放会卡住主线程
                }
            }
            catch (Exception e)
            {
                if (Constants.isEditor)
                {
                    UnityEngine.Debug.Log("CK : ------------------------------ DisposeAsync() : " + e.Message);
                }
            }
        };

#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
        dispose(www);
#else
        new System.Threading.Thread(dispose).Start(www);
#endif
    }
 public static String ModelDownloaded(ContentObject co)
 {
     System.Threading.ParameterizedThreadStart t = new System.Threading.ParameterizedThreadStart(ModelDownloaded_thread);
     System.Threading.Thread th = new System.Threading.Thread(t);
     th.Start(co);
     return "Thread fired";
 }
Пример #7
0
        private void ExcuteCodeLayerCheck(Plugin.Application.IAppGISRef AppHk)
        {
            #region 代码标准化图层检查主程序

            try
            {
                //高亮显示处理结果栏
                DevComponents.DotNetBar.PanelDockContainer PanelTip = _AppHk.DataTree.Parent as DevComponents.DotNetBar.PanelDockContainer;
                PanelTip.DockContainerItem.Selected = true;

                Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef;

                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(CheckLayer);
                System.Threading.Thread thread = new System.Threading.Thread(start);
                _AppHk.CurrentThread = thread;
                thread.Start(pAppForm);//调用图层标准检查方法
            }
            catch (Exception ex)
            {
                if (_AppHk.CurrentThread != null)
                {
                    _AppHk.CurrentThread = null;
                }
                MessageBox.Show(ex.ToString());
                return;
            }

            #endregion
        }
        /// <summary>
        /// Inherited member. Divides the simulation into threads, and begins.
        /// </summary>
        public override void Begin()
        {
            Random Rnd = new Random();

            //processorCT = UI.PachydermAc_PlugIn.Instance.ProcessorSpec();
            processorCT  = 4;
            Current_Ray  = new int[processorCT];
            Detections   = new List <int[]> [Receiver.Count, processorCT];
            SequenceList = new List <int[]> [Receiver.Count];

            T_List = new System.Threading.Thread[processorCT];

            for (int P_I = 0; P_I < processorCT; P_I++)
            {
                for (int i = 0; i < Receiver.Count; i++)
                {
                    Detections[i, P_I] = new List <int[]>();
                }

                Calc_Params T = new Calc_Params(P_I * Raycount / processorCT, (P_I + 1) * Raycount / processorCT, P_I, Rnd.Next());
                System.Threading.ParameterizedThreadStart TS = new System.Threading.ParameterizedThreadStart(delegate { Calculate(T); });
                T_List[P_I] = new System.Threading.Thread(TS);
                T_List[P_I].Start();
            }
        }
Пример #9
0
        /// <summary>
        /// 线重复数字化检查主函数
        /// </summary>
        /// <param name="_AppHk"></param>
        private void ExcuteLineDigitalDuplicateCheck(Plugin.Application.IAppGISRef _AppHk)
        {
            #region 取得进度条对象
            Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef;
            //选中数据处理树图项
            DevComponents.DotNetBar.PanelDockContainer PanelTip = _AppHk.DataTree.Parent as DevComponents.DotNetBar.PanelDockContainer;
            if (PanelTip != null)
            {
                PanelTip.DockContainerItem.Selected = true;
            }
            //取得进度条对象
            try
            {
                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(Line_redo);
                System.Threading.Thread thread = new System.Threading.Thread(start);
                _AppHk.CurrentThread = thread;
                thread.Start(pAppForm);
            }
            catch (Exception ex)
            {
                if (_AppHk.CurrentThread != null)
                {
                    _AppHk.CurrentThread = null;
                }
                SetCheckState.Message(pAppForm, "错误", ex.ToString());
                return;
            }

            #endregion
        }
Пример #10
0
 static public String ModelUploaded(ContentObject co)
 {
     System.Threading.ParameterizedThreadStart t = new System.Threading.ParameterizedThreadStart(ModelUploaded_thread);
     System.Threading.Thread th = new System.Threading.Thread(t);
     th.Start(co);
     return("Thread fired");
 }
Пример #11
0
        static void Main(string[] args)
        {
            try
            {
                   DuplexChannelFactory<IServerWithCallback> cf =
                 new DuplexChannelFactory<IServerWithCallback>(
                     new CallbackImpl(),
                     new NetTcpBinding(),
                     new EndpointAddress("net.tcp://192.168.1.1:9078/DataService"));
                  IServerWithCallback srv = cf.CreateChannel();
                  CounterStatues cs = new CounterStatues { CounterName = "Counter eeee", CounterNumber = "ttt", CounterStatus =CounterStatues.CounterStatusEn.Lock, UserId = "yahoo", IpAddress = "192.168.50.90" };

                srv.StartDataOutput(cs);
                System.Threading.ParameterizedThreadStart pt = new System.Threading.ParameterizedThreadStart(ServerChecker);
                System.Threading.Thread checkserver = new System.Threading.Thread(pt);
                checkserver.Start(srv);
                Console.Read();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try again ...");
                System.Threading.Thread.Sleep(600);
                Main(null);
            }
        }
Пример #12
0
        /// <summary>
        /// Inherited member. Divides the simulation into threads, and begins.
        /// </summary>
        public override void Begin()
        {
            Random Rnd = new Random();

            _processorCt = UI.PachydermAc_PlugIn.Instance.ProcessorSpec();
            _currentRay  = new int[_processorCt];
            _rayTotal    = new int[_processorCt];
            _lost        = new double[_processorCt];
            _eInit       = new double[_processorCt];
            _u           = new double[_processorCt];
            _v           = new double[_processorCt];
            _tlist       = new System.Threading.Thread[_processorCt];

            for (int P_I = 0; P_I < _processorCt; P_I++)
            {
                int start = (int)Math.Floor((double)P_I * Raycount / _processorCt);
                int end;
                if (P_I == _processorCt - 1)
                {
                    end = Raycount;
                }
                else
                {
                    end = (P_I + 1) * Raycount / _processorCt;
                }
                Calc_Params T = new Calc_Params(Room, start, end, P_I, Rnd.Next());
                System.Threading.ParameterizedThreadStart TS = new System.Threading.ParameterizedThreadStart(delegate { Calculate(T); });
                _tlist[P_I] = new System.Threading.Thread(TS);
                _tlist[P_I].Start();
            }

            System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.Batch;
        }
Пример #13
0
        static void Main(string[] args)
        {
            try
            {
                DuplexChannelFactory <IServerWithCallback> cf =
                    new DuplexChannelFactory <IServerWithCallback>(
                        new CallbackImpl(),
                        new NetTcpBinding(),
                        new EndpointAddress("net.tcp://192.168.1.1:9078/DataService"));
                IServerWithCallback srv = cf.CreateChannel();
                CounterStatues      cs  = new CounterStatues {
                    CounterName = "Counter eeee", CounterNumber = "ttt", CounterStatus = CounterStatues.CounterStatusEn.Lock, UserId = "yahoo", IpAddress = "192.168.50.90"
                };

                srv.StartDataOutput(cs);
                System.Threading.ParameterizedThreadStart pt = new System.Threading.ParameterizedThreadStart(ServerChecker);
                System.Threading.Thread checkserver          = new System.Threading.Thread(pt);
                checkserver.Start(srv);
                Console.Read();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try again ...");
                System.Threading.Thread.Sleep(600);
                Main(null);
            }
        }
        public static void RunOnNewThread(System.Threading.ParameterizedThreadStart del)
        {
            var thread = new System.Threading.Thread(del);

            thread.IsBackground = true;
            thread.Start();
        }
Пример #15
0
        private void ExcuteHangPointCheck(Plugin.Application.IAppGISRef AppHk)
        {
            #region 悬挂点检查主程序
            #region 取得进度条对象

            //取得进度条对象

            Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef;
            #endregion

            try
            {
                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(Point_dangles);
                System.Threading.Thread thread = new System.Threading.Thread(start);
                _AppHk.CurrentThread = thread;
                thread.Start(pAppForm);//悬挂点检查
            }
            catch (Exception ex)
            {
                if (_AppHk.CurrentThread != null)
                {
                    _AppHk.CurrentThread = null;
                }
                MessageBox.Show(ex.ToString());
            }
            #endregion
        }
Пример #16
0
 protected void SendNonQuery(string stmt)
 {
     var pts = new System.Threading.ParameterizedThreadStart(_SendNonQuery);
     System.Threading.Thread t = new System.Threading.Thread(pts);
     t.Start(stmt);
     t.Join();
 }
Пример #17
0
 static public void launchDiablo3Async(String module_name)
 {
     //Folgenden Code in eigene Methode einfügen:
     System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(AsyncMethod);
     System.Threading.Thread thread = new System.Threading.Thread(pts);
     thread.Start(module_name);
 }
Пример #18
0
        void RunGenerateCodeThread(bool generateAllModules)
        {
            this.pgBar.Value = 0;

            System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(RunGenerateCode);
            System.Threading.Thread thread = new System.Threading.Thread(threadStart);
            thread.Start(generateAllModules);
        }
Пример #19
0
        static void Main(string[] args)
        {
            System.Threading.ParameterizedThreadStart del = new System.Threading.ParameterizedThreadStart(Second);


            System.Threading.Thread th = new System.Threading.Thread(del);
            th.Start("Привет! ");
            Console.ReadKey();
        }
Пример #20
0
        public void MultithreadedPropertyAccess()
        {
            IEdmModel model = this.Parse(largerModelCsdl);

            BaseTypes     = new IEdmEntityType[10];
            Properties    = new IEnumerable <IEdmProperty> [10];
            PropertyTypes = new IEdmTypeReference[100];

            System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(PropertiesThreadFunction);

            for (int i = 0; i < 100; i++)
            {
                System.Threading.Thread newThread = new System.Threading.Thread(threadStart);
                newThread.Start(model);
            }

            int nonNullBaseTypeCount     = 0;
            int nonNullPropertiesCount   = 0;
            int nonNullPropertyTypeCount = 0;

            for (int i = 0; i < 10000; i++)
            {
                foreach (IEdmEntityType baseType in BaseTypes)
                {
                    Assert.AreNotEqual(BadBaseType, baseType, "Base Type");

                    if (baseType != null)
                    {
                        nonNullBaseTypeCount++;
                    }
                }

                foreach (IEnumerable <IEdmProperty> properties in Properties)
                {
                    Assert.AreNotEqual(BadProperties, properties, "Properties");

                    if (properties != null)
                    {
                        nonNullPropertiesCount++;
                    }
                }

                foreach (IEdmTypeReference type in PropertyTypes)
                {
                    Assert.AreNotEqual(BadTypeReference, type, "Property type");

                    if (type != null)
                    {
                        nonNullPropertyTypeCount++;
                    }
                }
            }

            Assert.IsTrue(nonNullBaseTypeCount > 50000, "Many base types");
            Assert.IsTrue(nonNullPropertiesCount > 50000, "Many properties enumerables");
            Assert.IsTrue(nonNullPropertyTypeCount > 500000, "Many property types");
        }
Пример #21
0
        private void cmdReProcessar_Click(object sender, EventArgs e)
        {
            painelLoad.Location    = _pontoCarregamento;
            gridClientes.Enabled   = false;
            cmdReProcessar.Enabled = false;

            System.Threading.ParameterizedThreadStart parametroThread = new System.Threading.ParameterizedThreadStart(carregaGrid);
            System.Threading.Thread th_processo = new System.Threading.Thread(parametroThread);
            th_processo.Start(true);
        }
Пример #22
0
        public void ThreadTest(int numberOfThreads)
        {
            for (int i = 0; i < numberOfThreads; i++)
            {
                System.Threading.ParameterizedThreadStart tStart = new System.Threading.ParameterizedThreadStart(Job2);
                System.Threading.Thread thread = new System.Threading.Thread(tStart);

                thread.Start(i);
            }
        }
Пример #23
0
 public static void StartScan()
 {
     foreach (KeyValuePair <string, AlarmPLCGroup> keyValuePair in alarmPlcType.PlcGroupDic)
     {
         System.Threading.ParameterizedThreadStart startFunction = new System.Threading.ParameterizedThreadStart(ScanThread);
         System.Threading.Thread threadScan = new System.Threading.Thread(startFunction);
         threadScan.IsBackground = true;
         threadScan.Start(keyValuePair.Key);
     }
 }
Пример #24
0
    private void Awake()
    {
        dict = new Dictionary <int, List <float> >();

        workLoad = nrItems / nrThreads;

        // load initial random data
        for (int i = 0; i < nrItems; i++)
        {
            dict.Add(i + 10, new List <float>());

            for (int j = 0; j < 5; j++)
            {
                dict[i + 10].Add(Random.Range(0f, 1f));
            }
        }

        // print unsorted data
        foreach (KeyValuePair <int, List <float> > entry in dict)
        {
            printEntry(entry);
        }


        List <System.Threading.Thread> threads = new List <System.Threading.Thread>();
        List <int> keys = new List <int>(dict.Keys);

        // sort data in parallel
        for (int i = 0; i < nrThreads; i++)
        {
            // pack parameters
            object param = new object[6] {
                i, nrThreads, workLoad, nrItems, dict, keys
            };
            System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(process);
            System.Threading.Thread worker = new System.Threading.Thread(pts);
            threads.Add(worker);
            worker.Start(param);
        }


        for (int i = 0; i < threads.Count; i++)
        {
            threads[i].Join();
        }

        print("main thread time: " + Time.realtimeSinceStartup);


        // print sorted data
        foreach (KeyValuePair <int, List <float> > entry in dict)
        {
            printEntry(entry);
        }
    }
Пример #25
0
        void BuildEvents_OnBuildDone(vsBuildScope Scope, vsBuildAction Action)
        {
            string solutionName = System.IO.Path.GetFileNameWithoutExtension(this._applicationObject.Solution.FullName);
            bool success = (this._applicationObject.Solution.SolutionBuild.LastBuildInfo == 0);

            // use another thread so that we dont slow the build down
            BuildInfo info = new BuildInfo(solutionName, success, true);
            System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(SendNotification);
            System.Threading.Thread t = new System.Threading.Thread(pts);
            t.Start(info);
        }
Пример #26
0
        void BuildEvents_OnBuildDone(vsBuildScope Scope, vsBuildAction Action)
        {
            string solutionName = System.IO.Path.GetFileNameWithoutExtension(this._applicationObject.Solution.FullName);
            bool   success      = (this._applicationObject.Solution.SolutionBuild.LastBuildInfo == 0);

            // use another thread so that we dont slow the build down
            BuildInfo info = new BuildInfo(solutionName, success, true);

            System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(SendNotification);
            System.Threading.Thread t = new System.Threading.Thread(pts);
            t.Start(info);
        }
Пример #27
0
        void BuildEvents_OnBuildProjConfigDone(string Project, string ProjectConfig, string Platform, string SolutionConfig, bool Success)
        {
            if (!Properties.Settings.Default.SolutionOnly)
            {
                string name = GetProjectName(Project);

                // use another thread so that we dont slow the build down
                BuildInfo info = new BuildInfo(name, Success, false);
                System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(SendNotification);
                System.Threading.Thread t = new System.Threading.Thread(pts);
                t.Start(info);
            }
        }
Пример #28
0
        void BuildEvents_OnBuildProjConfigDone(string Project, string ProjectConfig, string Platform, string SolutionConfig, bool Success)
        {
            if (!Properties.Settings.Default.SolutionOnly)
            {
                string name = GetProjectName(Project);

                // use another thread so that we dont slow the build down
                BuildInfo info = new BuildInfo(name, Success, false);
                System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(SendNotification);
                System.Threading.Thread t = new System.Threading.Thread(pts);
                t.Start(info);
            }
        }
Пример #29
0
        public void Start()
        {
            strFolder.Add("HBcAb");
            strFolder.Add("HBeAb");
            strFolder.Add("HBeAg");
            strFolder.Add("HBsAb");
            strFolder.Add("HBsAg");

            dsHandle  = new DataSetHandle();
            dsProject = dsHandle.GetDataSet("TEST_ITEM_ID,CHANNEL_NO", "TEST_INSTRUMENT_ITEM_CHANNEL", "INSTRUMENT_ID='" + strInstrumentID + "'");

            foreach (System.Data.DataRow dr in dsProject.Tables[0].Rows)
            {
                if (dr["CHANNEL_NO"].ToString().ToUpper() == "HBCAB")
                {
                    strHBcAbID = dr["TEST_ITEM_ID"].ToString();
                }
                else if (dr["CHANNEL_NO"].ToString().ToUpper() == "HBEAB")
                {
                    strHBeAbID = dr["TEST_ITEM_ID"].ToString();
                }
                else if (dr["CHANNEL_NO"].ToString().ToUpper() == "HBEAG")
                {
                    strHBeAgID = dr["TEST_ITEM_ID"].ToString();
                }
                else if (dr["CHANNEL_NO"].ToString().ToUpper() == "HBSAB")
                {
                    strHBsAbID = dr["TEST_ITEM_ID"].ToString();
                }
                else if (dr["CHANNEL_NO"].ToString().ToUpper() == "HBSAG")
                {
                    strHBsAgID = dr["TEST_ITEM_ID"].ToString();
                }
            }
            ;
            //通过线程去提取数据
            System.Threading.ParameterizedThreadStart ParStart = new System.Threading.ParameterizedThreadStart(GetResult);
            System.Threading.Thread threadSocket = new System.Threading.Thread(ParStart);
            object socketListen = "";

            threadSocket.Start(socketListen);

            //2010-05-11 22:16:49|22^^0||标本||aa31c32d-b539-4cfc-8dea-a0e6f85f33d7^3.9|
            //SaveResult saveResult = new SaveResult();

            //filePath = @"D:\新建文件夹\二院仪器数据\AnyTest\0Aux";
            fileName = "*.*";
            //fileName = "*.out";

            //writelog.Write(filePath,"log");
        }
Пример #30
0
        public static void StartThread()
        {
            //Needs EventLog work, exception thrown
            if (!EventLog.SourceExists("OverlayFS"))
            {
                EventLog.CreateEventSource("OverlayFS", "Application");
            }
            String appDirectory = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().Modules[0].FileName) + "\\";
            String settingsPath = appDirectory + "settings.xml";
            //Console.WriteLine("Loading settings from " + settingsPath);
            System.Xml.XmlDocument settingsXML = new System.Xml.XmlDocument();
            try
            {
                try
                {
                    settingsXML.Load(settingsPath);
                }
                catch (Exception)
                {
                    EventLog.WriteEntry("OverlayFS", "Error loading " + settingsPath, EventLogEntryType.Error);
                    throw;
                }

                foreach (System.Xml.XmlElement overlaySetting in settingsXML.DocumentElement)
                {
                    if (overlaySetting.Name.Equals("overlay"))
                    {
                        int logLevel;
                        if (!Int32.TryParse(overlaySetting.GetAttribute("logLevel"), out logLevel))
                        {
                            logLevel = (int)Logger.MessagePriority.Info;
                        }
                        OverlayFSMount ofsm = new OverlayFSMount();
                        ofsm.source = overlaySetting.GetAttribute("source");
                        ofsm.destination = overlaySetting.GetAttribute("destination");
                        ofsm.logLevel = logLevel;

                        System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(MountThread);
                        System.Threading.Thread t = new System.Threading.Thread(pts);
                        t.Start(ofsm);

                    }
                }
            }
            catch (Exception e)
            {
                //Console.Error.WriteLine(e.Message);
                EventLog.WriteEntry("OverlayFS", e.Message + "\n\n" + e.StackTrace, EventLogEntryType.Error);
                Console.ReadLine();
            }
        }
Пример #31
0
        protected override void OnStart(string[] args)
        {
            var urls = GMS.Core.Config.CachedConfigContext.Current.UrlConfig.Urls;

            foreach (var urlInfo in urls)
            {
                var t = new System.Threading.ParameterizedThreadStart(ScheduleTask);
                if (urlInfo.Ready)
                {
                    cron_daemon.AddJob(urlInfo.Schedule, t, urlInfo);
                }
            }

            cron_daemon.Start();
        }
 private void Loop_Click(object sender, EventArgs e)
 {
     if (Loop.Text == "Loop")
     {
         Time_Preview.Enabled = false;
         Loop.Text            = "Pause";
         System.Threading.ParameterizedThreadStart St = new System.Threading.ParameterizedThreadStart(delegate { LoopStart(this.Frame_Rate.Value * Seconds.Value); });
         T = new System.Threading.Thread(St);
         T.Start();
     }
     else
     {
         Time_Preview.Enabled = true;
         Loop.Text            = "Loop";
         T.Abort();
     }
 }
Пример #33
0
 private void Flip_Toggle_Click(object sender, EventArgs e)
 {
     Update_Scale();
     if (Flip_Toggle.Text == "Flip")
     {
         this.Flip_Toggle.Text = "Pause";
         FC = new ForCall(Step_Forward);
         TC = new T_Call(Update_T);
         System.Threading.ParameterizedThreadStart St = new System.Threading.ParameterizedThreadStart(delegate { Flip_Forward(); });
         T = new System.Threading.Thread(St);
         T.Start();
     }
     else
     {
         Flip_Toggle.Text = "Flip";
         T.Abort();
     }
 }
 private void Loop_Click(object sender, EventArgs e)
 {
     if (Loop.Text == "Loop")
     {
         Running = true;
         Time_Preview.Enabled = false;
         Loop.Text            = "Pause";
         System.Threading.ParameterizedThreadStart St = new System.Threading.ParameterizedThreadStart(delegate { LoopStart(); });
         T = new System.Threading.Thread(St);
         T.Start();
     }
     else
     {
         Running = false;
         Time_Preview.Enabled = true;
         Loop.Text            = "Loop";
     }
 }
 public static void StartScan()
 {
     PLCControlGroup = new Dictionary <string, WorldGeneralLib.PLC.PLCControlGroup>();
     foreach (KeyValuePair <string, PLCBaseClass> keyValuePair in PLCDriverManageClass.dicDrivers)
     {
         PLCControlGroup plcGroup = new PLCControlGroup();
         PLCScanTime = new Dictionary <string, double>();
         PLCScanTime.Add(keyValuePair.Key, 0.0);
         PLCControlGroup.Add(keyValuePair.Key, plcGroup);
         System.Threading.ParameterizedThreadStart startFunction = new System.Threading.ParameterizedThreadStart(ScanThread);
         System.Threading.Thread threadScan = new System.Threading.Thread(startFunction);
         threadScan.IsBackground = true;
         threadScan.Start(keyValuePair.Key);
     }
     //System.Threading.Thread threadScan = new System.Threading.Thread(ScanThread);
     //threadScan.IsBackground = true;
     //threadScan.Start();
 }
Пример #36
0
        public void Thread()
        {
            //winform中的线程
            //  System.Threading.Thread;
            //wpf环境中的线程
            //System.Windows.Threading.Dispatcher.CurrentDispatcher.Thread
            System.Threading.ParameterizedThreadStart ts = new System.Threading.ParameterizedThreadStart(this.newActionThread2);//一个线程执行委托


            for (int i = 0; i <= 100; i++)
            {
                System.Threading.Thread t = new System.Threading.Thread(ts);
                System.Threading.Thread.Sleep(100);
                t.Start(i);
                this.label2.Content = progressBar1.Value++ + "%";
                this.DoEvents();//界面刷新
            }
        }
Пример #37
0
 /*
  * Object handles logging of a log event to the window
  * @param le is the log event object to be logged
  */
 public void AddLogEvent(object le)
 {
     // if the logger is busy, invoke it
     if (listBox1.InvokeRequired)
     {
         System.Threading.ParameterizedThreadStart d = new System.Threading.ParameterizedThreadStart(AddLogEvent);
         listBox1.Invoke(d, new object[] { le });
     }
     // else log the message
     else
     {
         LogEvent e = (LogEvent)le;
         listBox1.Items.Insert(0, e.time.ToString() + " " + e.Module + ": " + e.Message);
         while (listBox1.Items.Count > 1000)
         {
             listBox1.Items.RemoveAt(1000);
         }
     }
 }
Пример #38
0
		private void ProcessXPSFile(FileInfo xpsF, ParallelLoopState pls, long l)
		{
			Log("Processing: " + xpsF.Name);
			string xpsFileName = xpsF.FullName;

			try
			{

				XpsDocument xpsDoc = new XpsDocument(xpsFileName, System.IO.FileAccess.Read);

				System.Threading.ParameterizedThreadStart ts = new System.Threading.ParameterizedThreadStart(ProcessXPSonSTA);
				System.Threading.Thread tProcess = new System.Threading.Thread(ts);
				tProcess.SetApartmentState(System.Threading.ApartmentState.STA);
				tProcess.Start(new XPSParams() { xpsFileName = xpsFileName, xpsDoc = xpsDoc });
			}
			catch (Exception e)
			{
				Log(e.ToString());
			}
		}
        /// <summary>
        /// Inherited member. Divides the simulation into threads, and begins.
        /// </summary>
        public override void Begin()
        {
            Random Rnd = new Random();
            processorCT = UI.PachydermAc_PlugIn.Instance.ProcessorSpec();
            Current_Ray = new int[processorCT];
            Detections = new List<int[]>[Receiver.Count, processorCT];
            SequenceList = new List<int[]>[Receiver.Count];

            T_List = new System.Threading.Thread[processorCT];

            for (int P_I = 0; P_I < processorCT; P_I++)
            {
                for (int i = 0; i < Receiver.Count; i++)
                {
                    Detections[i, P_I] = new List<int[]>();
                }
                 
                Calc_Params T = new Calc_Params(P_I * Raycount / processorCT, (P_I + 1) * Raycount / processorCT, P_I, Rnd.Next());
                System.Threading.ParameterizedThreadStart TS = new System.Threading.ParameterizedThreadStart(delegate { Calculate(T); });
                T_List[P_I] = new System.Threading.Thread(TS);
                T_List[P_I].Start();
            }
        }
Пример #40
0
        public void parseCommand(TwitchUserMessage userMessage)
        {
            IList<string> commands = commandList.Keys.ToList();
            string innerCommand = string.Empty;
            foreach (string command in commands)
            {
                innerCommand = commandPrefix + command;
                Regex regex = new Regex(innerCommand + ".*");
                if (regex.IsMatch(userMessage.Message))
                {
                    System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(RunCommand);
                    System.Threading.Thread t = new System.Threading.Thread(pts);
                    CommandParameter cp = new CommandParameter();
                    cp.ircClient = this;
                    cp.userMessage = userMessage;
                    cp.ircCommand = commandList[command];

                    //Run on a thread to avoid huge queues
                    t.Start(cp);

                    //commandList[command](userMessage);
                }
            }
        }
 private void Flip_Toggle_Click(object sender, EventArgs e)
 {
     Update_Scale();
     if (Flip_Toggle.Text == "Flip")
     {
         this.Flip_Toggle.Text = "Pause";
         FC = new ForCall(Step_Forward);
         TC = new T_Call(Update_T);
         System.Threading.ParameterizedThreadStart St = new System.Threading.ParameterizedThreadStart(delegate { Flip_Forward(); });
         T = new System.Threading.Thread(St);
         T.Start();
     }
     else 
     {
         Flip_Toggle.Text = "Flip";
         T.Abort();
     }
 }
Пример #42
0
        //Search the repo for a list of pids that match a search term
        //This returns the results as a list of pairs of titles and pids
        //will eventually take a pagenum and other params for more advanced searching
        public List<SearchResult> Search(string terms, string key)
        {
            List<SearchResult> results = new List<SearchResult>();
            List<FederateRecord> federates = mFederateRegister.GetAllFederateRecords();
            List<System.Threading.Thread> threads = new List<System.Threading.Thread>();
            foreach (FederateRecord fr in federates)
            {
                System.Threading.ParameterizedThreadStart ts = new System.Threading.ParameterizedThreadStart(Search1Delegate);
                System.Threading.Thread t = new System.Threading.Thread(ts);

                SearchStart ss = new SearchStart();
                ss.Authorization = WebOperationContext.Current.IncomingRequest.Headers["Authorization"];
                ss.terms = terms;
                ss.results = results;
                ss.fed = fr;
                //Search1Delegate(ss);
                t.Start(ss);
                threads.Add(t);
            }
            bool done = false;
            int totalSleeps = 0;
            while (!done && totalSleeps < 30)
            {
                done = true;
                foreach (System.Threading.Thread t in threads)
                {
                    if (t.IsAlive)
                        done = false;
                }
                System.Threading.Thread.Sleep(300);
                totalSleeps++;
            }
            return results;
        }
Пример #43
0
        /// <summary>
        /// Used by specular raytracer.
        /// </summary>
        /// <param name="Sequences">List of surface index sequences to try.</param>
        public void Lookup_Sequences(List<int[]>[] Sequences)
        {
            processorCT = UI.PachydermAc_PlugIn.Instance.ProcessorSpec();
            ThreadPaths = new List<Deterministic_Reflection>[Rec.Length,processorCT];
            int SrfCT = Room.PlaneCount;
            CurrentSrf = new int[processorCT];
            Random R = new Random();
            T_List = new System.Threading.Thread[processorCT];
            for (int p = 0; p < Rec.Length; p++)
            {
                for (int P_I = 0; P_I < processorCT; P_I++)
                {
                    ThreadPaths[p, P_I] = new List<Deterministic_Reflection>();
                    Calc_Params T = new Calc_Params(P_I * Sequences[p].Count / processorCT, (P_I + 1) * Sequences[p].Count / processorCT, P_I, R.Next());
                    System.Threading.ParameterizedThreadStart TS = new System.Threading.ParameterizedThreadStart(delegate
                    {
                        for (int i = T.StartIndex; i < T.EndIndex; i++)
                        {
                            ProcessPath(Sequences[p][i], T.ThreadID, p);
                        }
                    });
                    T_List[P_I] = new System.Threading.Thread(TS);
                    T_List[P_I].Start();
                }
                do
                {
                    System.Threading.Thread.Sleep(1000);
                    if (ThreadState() != System.Threading.ThreadState.Running) break;
                } while (true);

                for (int t = 0; t < processorCT; t++)
                {
                    ValidPaths[p].AddRange(ThreadPaths[p, t]);
                }
            }
        }
            private void Preview_Click(object sender, EventArgs e)
            {
                Loop.Enabled = false;
                ForwButton.Enabled = false;
                BackButton.Enabled = false;
                PachydermAc_PlugIn plugin = PachydermAc_PlugIn.Instance;

                if (PreviewDisplay != null) PreviewDisplay.Enabled = false;

                max = (int)(Frame_Rate.Value * Seconds.Value);

                Point3d[] SPT;

                if (!plugin.SourceOrigin(out SPT))
                {
                    Rhino.RhinoApp.WriteLine("Model geometry not specified... Exiting calculation...");
                    return;
                }

                if (T != null && T.ThreadState == System.Threading.ThreadState.Running) T.Abort();
                PreviewDisplay = null;

                Pach_GetModel_Command Model = Pach_GetModel_Command.Instance;
                if (object.ReferenceEquals(RoomSelection.SelectedItem, "Use Entire Model"))
                {
                    Model.Rel_Humidity = 50;//(double)Rel_Humidity.Value;
                    Model.Air_Temp = (double)Air_Temp.Value;
                    Model.Atm_pressure = 1000;//(double)Air_Pressure.Value;
                    Model.Atten_Choice = 0;//Atten_Method.SelectedIndex;
                    Rhino.RhinoApp.RunScript("GetModel", false);
                }

                plugin.Source(out Source);

                if (MeshWave)
                {
                    for (int i = 0; i < Source.Length; i++) Source[i] = new GeodesicMeshSource(plugin.GetSourceSWL(i), Source[i].Origin(), (int)RT_Count.Value, i);
                }

                ParticleRays[] RTParticles = new ParticleRays[Source.Length];
                List<Point3d> L = new List<Point3d>();
                for (int i = 0; i < Source.Length; i++)
                {
                    L.Add(Source[i].Origin());
                }
                for (int j = 0; j < Source.Length; j++)
                {
                    if (plugin.Geometry_Spec() == 0)
                    {
                        Model.Ret_NURBS_Scene.partition(L);
                        RTParticles[j] = new ParticleRays(Source[j], Model.Ret_NURBS_Scene, (int)RT_Count.Value, CutOffLength());
                    }
                    else
                    {
                        Model.Ret_Mesh_Scene.partition(L);
                        RTParticles[j] = new ParticleRays(Source[j], Model.Ret_Mesh_Scene, (int)RT_Count.Value, CutOffLength());
                    }

                    RTParticles[j].Begin();
                }

                PreviewDisplay = new WaveConduit(RTParticles, scale, new double[2] { (double)Param_Min.Value, (double)Param_Max.Value }, Model.Ret_Mesh_Scene);
                ForwButton.Enabled = true;
                BackButton.Enabled = true;
                Loop.Enabled = true;
                Loop.Text = "Stop";
                FC = new ForCall(Forw_proc);
                System.Threading.ParameterizedThreadStart St = new System.Threading.ParameterizedThreadStart(delegate { LoopStart((int)(this.Frame_Rate.Value * Seconds.Value)); });
                T = new System.Threading.Thread(St);
                T.Start();
            }
Пример #45
0
 public Config(System.Threading.ParameterizedThreadStart routine,
               object argument, bool reporterrors)
 {
     Routine = routine;
     Argument = argument;
     ReportErrors = reporterrors;
 }
		/// <summary>
		/// Runs the test given a browser type.
		/// </summary>
		/// <param name="browserType"></param>
		public void Run(BrowserType browserType)
		{
            MainForm mainWindow = _parent.GetMainForm;
		    this.testResults.Clear();

			if (mainWindow.getBreakPointStatus())
				EnableAllBreakPoints();
			else
				DisableAllBreakPoints();
			System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(runScript);

			_currentTestThread = new System.Threading.Thread(start);

			_currentTestThread.SetApartmentState(System.Threading.ApartmentState.STA);
			_currentTestBrowserType = browserType;
			_currentTestThread.Start(this._textEditor.Document.Lines);
		}
Пример #47
0
        private void btnFetchEmails_Click(object sender, EventArgs e)
        {
            lvInbox.Items.Clear();

            try
            {
                EmailAutomationModel model = generateModel();

                if (rdbRead.Checked)
                    model.MailStatus = 2;
                else if (rdbUnread.Checked)
                    model.MailStatus = 3;
                else
                    model.MailStatus = 1;

                model.MailsToDisplay = Convert.ToInt32(tbMailCount.Text.Trim());

                model.MailBox = (rdbImap.Checked) ? cmbFolders.SelectedValue.ToString() : "Inbox";

                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(_presentor.PlayEmailAutomation);
                System.Threading.Thread t = new System.Threading.Thread(start);
                t.Start(model);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #48
0
        /// <summary>
        /// Inherited member. Divides the simulation into threads, and begins.
        /// </summary>
        public override void Begin()
        {
            processorCT = UI.PachydermAc_PlugIn.Instance.ProcessorSpec();
            ThreadPaths = new List<Deterministic_Reflection>[Rec.Length, processorCT];
            int SrfCT = Room.PlaneCount;
            CurrentSrf = new int[processorCT];
            CurrentEdge = new int[processorCT];
            Rnd = new Random[processorCT];
            T_List = new System.Threading.Thread[processorCT];
            elementCt = Room.PlaneCount + ((this.Diffraction) ? Room.EdgeCount : 0);

            for (int P_I = 0; P_I < processorCT; P_I++)
            {
                for (int i = 0; i < Rec.Length; i++)
                {
                    ThreadPaths[i,P_I] = new List<Deterministic_Reflection>();
                    ValidPaths[i] = new List<Deterministic_Reflection>();
                }
                int start = (int)Math.Floor((double)P_I * SrfCT / processorCT);
                int end;
                if (P_I == processorCT - 1) end = SrfCT;
                else end = (P_I + 1) * SrfCT / processorCT;
                
                Calc_Params T = new Calc_Params(start, end, P_I, Room.R_Seed.Next());
                System.Threading.ParameterizedThreadStart TS = new System.Threading.ParameterizedThreadStart(delegate { Calculate(T); });
                T_List[P_I] = new System.Threading.Thread(TS);
                T_List[P_I].Start();
            }
        }
 private void Loop_Click(object sender, EventArgs e)
 {
     if (Loop.Text == "Loop")
     {
         Time_Preview.Enabled = false;
         Loop.Text = "Pause";
         System.Threading.ParameterizedThreadStart St = new System.Threading.ParameterizedThreadStart(delegate { LoopStart(this.Frame_Rate.Value * Seconds.Value); });
         T = new System.Threading.Thread(St);
         T.Start();
     }
     else
     {
         Time_Preview.Enabled = true;
         Loop.Text = "Loop";
         T.Abort();
     }
 }
 private void Loop_Click(object sender, EventArgs e)
 {
     if (Loop.Text == "Loop")
     {
         Running = true;
         Time_Preview.Enabled = false;
         Loop.Text = "Pause";
         System.Threading.ParameterizedThreadStart St = new System.Threading.ParameterizedThreadStart(delegate { LoopStart(); });
         T = new System.Threading.Thread(St);
         T.Start();
     }
     else
     {
         Running = false;
         Time_Preview.Enabled = true;
         Loop.Text = "Loop";
     }
 }
        /// <summary>
        /// Inherited member. Divides the simulation into threads, and begins.
        /// </summary>
        public override void Begin()
        {
            Random Rnd = new Random();
            _processorCt = UI.PachydermAc_PlugIn.Instance.ProcessorSpec();
            _currentRay = new int[_processorCt];
            _rayTotal = new int[_processorCt];
            _lost = new double[_processorCt];
            _eInit = new double[_processorCt];
            _u = new double[_processorCt];
            _v = new double[_processorCt];
            _tlist = new System.Threading.Thread[_processorCt];
            
            for (int P_I = 0; P_I < _processorCt; P_I++)
            {
                int start = (int)Math.Floor((double)P_I * Raycount / _processorCt);
                int end;
                if (P_I == _processorCt - 1) end = Raycount;
                else end = (P_I + 1) * Raycount / _processorCt;
                Calc_Params T = new Calc_Params(Room, start, end, P_I, Rnd.Next());
                System.Threading.ParameterizedThreadStart TS = new System.Threading.ParameterizedThreadStart(delegate { Calculate(T); });
                _tlist[P_I] = new System.Threading.Thread(TS);
                _tlist[P_I].Start();
            }

            System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.Batch;
        }
Пример #52
0
        public void MultithreadedAnnotationsOnLargerModel()
        {
            IEdmModel model = this.Parse(largerModelCsdl);

            string bogus = "http://bogus.com";
            string goop = "goop";
            string droop = "droop";
            string scoop = "scoop";

            List<IEdmDirectValueAnnotationBinding> setters = new List<IEdmDirectValueAnnotationBinding>();
            List<IEdmDirectValueAnnotationBinding> getters = new List<IEdmDirectValueAnnotationBinding>();

            foreach (IEdmSchemaElement element in model.SchemaElements)
            {
                setters.Add(new EdmDirectValueAnnotationBinding(element, bogus, goop, 0));
                setters.Add(new EdmDirectValueAnnotationBinding(element, bogus, droop, 0));
                setters.Add(new EdmDirectValueAnnotationBinding(element, bogus, scoop, 0));

                IEdmEntityType entityType = element as IEdmEntityType;
                if (entityType != null)
                {
                    foreach (IEdmStructuralProperty property in entityType.DeclaredProperties)
                    {
                        setters.Add(new EdmDirectValueAnnotationBinding(property, bogus, goop, 0));
                        setters.Add(new EdmDirectValueAnnotationBinding(property, bogus, droop, 0));
                        setters.Add(new EdmDirectValueAnnotationBinding(property, bogus, scoop, 0));
                    }
                }
            };

            foreach (IEdmSchemaElement element in model.SchemaElements)
            {
                getters.Add(new EdmDirectValueAnnotationBinding(element, bogus, goop));
                getters.Add(new EdmDirectValueAnnotationBinding(element, bogus, droop));
                getters.Add(new EdmDirectValueAnnotationBinding(element, bogus, scoop));

                IEdmEntityType entityType = element as IEdmEntityType;
                if (entityType != null)
                {
                    getters.Add(new EdmDirectValueAnnotationBinding(entityType.FindProperty("Name"), bogus, goop));
                    getters.Add(new EdmDirectValueAnnotationBinding(entityType.FindProperty("Shame"), bogus, droop));
                    getters.Add(new EdmDirectValueAnnotationBinding(entityType.FindProperty("Pame"), bogus, scoop));
                }
            };

            Assert.IsTrue(setters.Count() >= 330, "Setters count");
            Assert.IsTrue(getters.Count() >= 60, "Getters count");

            model.SetAnnotationValues(setters);

            bool foundNonzero = false;

            ThreadIndexForLargerModel = 0;
            System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(AnnotationsThreadFunctionForLargerModel);

            for (int i = 0; i < 100; i++)
            {
                System.Threading.Thread newThread = new System.Threading.Thread(threadStart);
                newThread.Start(model);

                object[] values = model.GetAnnotationValues(getters);
                int firstValue = (int)values[0];
                foreach (object value in values)
                {
                    Assert.AreEqual(firstValue, (int)value, "Person and name values");
                }
            }

            for (int i = 0; i < 10000; i++)
            {
                object[] values = model.GetAnnotationValues(getters);
                int firstValue = (int)values[0];
                if (firstValue != 0)
                {
                    foundNonzero = true;
                }

                foreach (object value in values)
                {
                    Assert.AreEqual(firstValue, (int)value, "Person and name values");
                }
            }

            Assert.IsTrue(foundNonzero, "Nonzero value");
        }
Пример #53
0
        //Search the repo for a list of pids that match a search term
        //This returns the results as a list of pairs of titles and pids
        //will eventually take a pagenum and other params for more advanced searching
        public List<SearchResult> AdvancedSearch(string mode, string terms, string key)
        {
            List<SearchResult> results = new List<SearchResult>();
            List<FederateRecord> federates = mFederateRegister.GetAllFederateRecords();
            List<System.Threading.Thread> threads = new List<System.Threading.Thread>();
            foreach (FederateRecord fr in federates)
            {
                System.Threading.ParameterizedThreadStart ts = new System.Threading.ParameterizedThreadStart(AdvancedSearch1Delegate);
                System.Threading.Thread t = new System.Threading.Thread(ts);

                SearchStart ss = new SearchStart();
                ss.terms = terms;
                ss.results = results;
                ss.mode = mode;
                ss.fed = fr;
                //Search1Delegate(ss);
                t.Start(ss);
                threads.Add(t);
            }
            bool done = false;
            int totalSleeps = 0;
            while (!done && totalSleeps < 30)
            {
                done = true;
                foreach (System.Threading.Thread t in threads)
                {
                    if (t.IsAlive)
                        done = false;
                }
                System.Threading.Thread.Sleep(300);
                totalSleeps++;
            }
            return results;
        }
Пример #54
0
        public void MultithreadedAnnotations()
        {
            this.SetupModels();

            IEdmEntityType person = baseModel.FindEntityType("foo.Person");
            Assert.IsNotNull(person, "Personage");

            IEdmProperty name = person.FindProperty("Name");
            Assert.IsNotNull(name, "Person Name");

            string bogus = "http://bogus.com";
            string goop = "goop";
            string droop = "droop";
            string scoop = "scoop";

            var setters = new IEdmDirectValueAnnotationBinding[]
            {
                new EdmDirectValueAnnotationBinding(person, bogus, goop, 0),
                new EdmDirectValueAnnotationBinding(person, bogus, droop, 0),
                new EdmDirectValueAnnotationBinding(person, bogus, scoop, 0),
                new EdmDirectValueAnnotationBinding(name, bogus, goop, 0),
                new EdmDirectValueAnnotationBinding(name, bogus, droop, 0),
                new EdmDirectValueAnnotationBinding(name, bogus, scoop, 0)
            };

            var getters = new IEdmDirectValueAnnotationBinding[]
            {
                new EdmDirectValueAnnotationBinding(person, bogus, goop),
                new EdmDirectValueAnnotationBinding(person, bogus, droop),
                new EdmDirectValueAnnotationBinding(person, bogus, scoop),
                new EdmDirectValueAnnotationBinding(name, bogus, goop),
                new EdmDirectValueAnnotationBinding(name, bogus, droop),
                new EdmDirectValueAnnotationBinding(name, bogus, scoop)
            };

            baseModel.SetAnnotationValues(setters);

            bool foundNonzero = false;

            ThreadIndex = 0;
            System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(AnnotationsThreadFunction);

            for (int i = 0; i < 100; i++)
            {
                System.Threading.Thread newThread = new System.Threading.Thread(threadStart);
                newThread.Start(baseModel);

                object[] values = baseModel.GetAnnotationValues(getters);
                int firstValue = (int)values[0];
                foreach (object value in values)
                {
                    Assert.AreEqual(firstValue, (int)value, "Person and name values");
                }
            }

            for (int i = 0; i < 10000; i++)
            {
                object[] values = baseModel.GetAnnotationValues(getters);
                int firstValue = (int)values[0];
                if (firstValue != 0)
                {
                    foundNonzero = true;
                }

                foreach (object value in values)
                {
                    Assert.AreEqual(firstValue, (int)value, "Person and name values");
                }
            }

            Assert.IsTrue(foundNonzero, "Nonzero value");
        }
Пример #55
0
        public void MultithreadedPropertyAccess()
        {
            IEdmModel model = this.Parse(largerModelCsdl);
            BaseTypes = new IEdmEntityType[10];
            Properties = new IEnumerable<IEdmProperty>[10];
            PropertyTypes = new IEdmTypeReference[100];

            System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(PropertiesThreadFunction);

            for (int i = 0; i < 100; i++)
            {
                System.Threading.Thread newThread = new System.Threading.Thread(threadStart);
                newThread.Start(model);
            }

            int nonNullBaseTypeCount = 0;
            int nonNullPropertiesCount = 0;
            int nonNullPropertyTypeCount = 0;

            for (int i = 0; i < 10000; i++)
            {
                foreach (IEdmEntityType baseType in BaseTypes)
                {
                    Assert.AreNotEqual(BadBaseType, baseType, "Base Type");

                    if (baseType != null)
                    {
                        nonNullBaseTypeCount++;
                    }
                }

                foreach (IEnumerable<IEdmProperty> properties in Properties)
                {
                    Assert.AreNotEqual(BadProperties, properties, "Properties");

                    if (properties != null)
                    {
                        nonNullPropertiesCount++;
                    }
                }

                foreach (IEdmTypeReference type in PropertyTypes)
                {
                    Assert.AreNotEqual(BadTypeReference, type, "Property type");

                    if (type != null)
                    {
                        nonNullPropertyTypeCount++;
                    }
                }
            }

            Assert.IsTrue(nonNullBaseTypeCount > 50000, "Many base types");
            Assert.IsTrue(nonNullPropertiesCount > 50000, "Many properties enumerables");
            Assert.IsTrue(nonNullPropertyTypeCount > 500000, "Many property types");
        }
Пример #56
0
        /// <summary>
        /// RSS镜像更新用户blog,一天更新一次,目前只能通过标题来判断日记是否存在
        /// </summary>
        /// <param name="UserId">UID</param>


        public static void UpdateLogByRssLink(int UserId)
        {
            System.Threading.ParameterizedThreadStart strat = new System.Threading.ParameterizedThreadStart(UpdateCss);
            System.Threading.Thread th = new System.Threading.Thread(strat);
            th.Start(UserId);
       }
Пример #57
0
        public void ShowCurrentSourceAsMzML()
        {
            GraphForm currentGraphForm = CurrentGraphForm;
            if( currentGraphForm == null )
                throw new Exception( "current graph should not be null" );

            Form previewForm = new Form();
            previewForm.StartPosition = FormStartPosition.CenterParent;
            previewForm.Text = "MzML preview of " + currentGraphForm.PaneList[0][0].Source.Source.CurrentFilepath;
            TextBox previewText = new TextBox();
            previewText.Multiline = true;
            previewText.ReadOnly = true;
            previewText.Dock = DockStyle.Fill;
            previewForm.Controls.Add( previewText );

            //previewForm.Show( mainForm );
            //Application.DoEvents();

            string tmp = Path.GetTempFileName();
            System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart( startWritePreviewMzML );
            System.Threading.Thread writeThread = new System.Threading.Thread( threadStart );
            writeThread.Start( new KeyValuePair<string, MSData>( tmp, currentGraphForm.PaneList[0][0].Source.Source.MSDataFile ));
            writeThread.Join( 1000 );
            while( writeThread.IsAlive )
            {
                FileStream tmpStream = File.Open( tmp, FileMode.Open, FileAccess.Read, FileShare.None );
                previewText.Text = new StreamReader( tmpStream ).ReadToEnd();
                writeThread.Join( 1000 );
            }
        }
Пример #58
0
 static public void launchDiablo3Async(String module_name)
 {
     //Folgenden Code in eigene Methode einfügen:
     System.Threading.ParameterizedThreadStart pts = new System.Threading.ParameterizedThreadStart(AsyncMethod);
     System.Threading.Thread thread = new System.Threading.Thread(pts);
     thread.Start(module_name);
 }