public void Test()
        {
            var random = new Random();

            System.Threading.ThreadStart t = new System.Threading.ThreadStart(() => {
                while (true)
                {
                    if (0L == DotNetty.Common.Utilities.RandomExtensions.NextLong(random))
                    {
                        throw new Exception("NextLong return 0");
                    }
                    else
                    {
                        Debug.WriteLine(DateTime.Now.ToFileTime());
                    }
                }
            });

            Enumerable.Range(0, 1).ToList()
            .ForEach(x => new System.Threading.Thread(t)
            {
                IsBackground = true
            }.Start());

            System.Threading.Thread.Sleep(-1);
        }
Exemplo n.º 2
0
        public void ExcuteMultiTask(ref List <CheckTask> availableTasks)
        {
            if (m_MultiTask == null)
            {
                return;
            }

            List <CheckTask> tempTasks = null;

            System.Threading.ThreadStart threadStart = delegate
            {
                m_MultiTask.CheckingTaskChanged += new TaskCheckEventsHandler(m_MultiTask_CheckingTaskChanged);
                m_MultiTask.CreatingTaskChanged += new TaskCreateEventsHandler(m_MultiTask_CreatingTaskChanged);
                m_MultiTask.TaskChecked         += new TaskCheckEventsHandler(m_MultiTask_TaskChecked);
                m_MultiTask.TaskCreated         += new TaskCreateEventsHandler(m_MultiTask_TaskCreated);

                //AdaptCheckerEvents(m_MultiTask.TaskChecker);
                m_MultiTask.Excute(ref tempTasks);
                // availableTasks = tempTasks;


                ThreadStart invokeFuction = delegate
                {
                    lblOperateType.Text = "所有任务执行完成";
                };
                this.Invoke(invokeFuction);
            };

            System.Threading.Thread thread = new System.Threading.Thread(threadStart);
            thread.Start();

            this.ShowDialog();

            availableTasks = tempTasks;
        }
Exemplo n.º 3
0
        public MainPage()
        {
            InitializeComponent();
            initializeStoredEvents();
            initializeMyEvents();

            App.Current.MainPage = new NavigationPage();
            Content            = animationStack;
            lastDay            = -1;
            fadingGrid         = false;
            populatingGrid     = true;
            animating          = true;
            scrollView.Content = GlobalVariables.grid2;

            //initialize indicator for a new day refresh
            newDayIndicator = new ActivityIndicator();
            newDayIndicator.HorizontalOptions = LayoutOptions.FillAndExpand;
            newDayIndicator.VerticalOptions   = LayoutOptions.Center;
            newDayIndicator.Color             = Color.White;
            newDayIndicator.BackgroundColor   = Color.Black;
            newDayIndicator.IsEnabled         = true;
            newDayIndicator.IsRunning         = true;

            //start opening animation
            System.Threading.ThreadStart openingAnimationStart  = animateOpening;
            System.Threading.Thread      openingAnimationThread = new System.Threading.Thread(openingAnimationStart);
            openingAnimationThread.IsBackground = true;
            openingAnimationThread.Start();

            //timer
            objTimer          = new System.Timers.Timer();
            objTimer.Interval = 500;
            objTimer.Elapsed += ObjTimer_Elapsed;
            objTimer.Start();
        }
Exemplo n.º 4
0
 private static void ToSTA(ST.ThreadStart code)
 {
     ST.Thread t = new ST.Thread(code);
     t.SetApartmentState(ST.ApartmentState.STA);
     t.Start();
     t.Join();
 }
Exemplo n.º 5
0
        public virtual bool ShowBackgroundCancelDialog(int millisecondsDelay, System.Threading.ThreadStart threadstart, IExternalDrivenBackgroundMonitor monitor)
        {
            var t = new System.Threading.Thread(threadstart);

            t.Start();
            return(ShowBackgroundCancelDialog(millisecondsDelay, t, monitor));
        }
Exemplo n.º 6
0
        public static void DownloadInstallPatchFromURI(string downloadUri, string destinationPath)
        {
            File.Delete(destinationPath);            //fixes a minor bug
            WebRequest   wr       = WebRequest.Create(downloadUri);
            WebResponse  webResp  = wr.GetResponse();
            int          fileSize = (int)webResp.ContentLength / 1024;
            FormProgress FormP    = new FormProgress();

            //start the thread that will perform the download
            System.Threading.ThreadStart downloadDelegate =
                delegate { DownloadInstallPatchWorker(downloadUri, destinationPath, ref FormP); };
            Thread workerThread = new System.Threading.Thread(downloadDelegate);

            workerThread.Start();
            //display the progress dialog to the user:
            FormP.MaxVal = (double)fileSize / 1024;
            FormP.NumberMultiplication = 100;
            FormP.DisplayText          = "?currentVal MB of ?maxVal MB copied";
            FormP.NumberFormat         = "F";
            FormP.ShowDialog();
            if (FormP.DialogResult == DialogResult.Cancel)
            {
                workerThread.Abort();
                return;
            }
            MsgBox.Show(FormP, "Download succeeded.  Setup program will now begin." +
                        "When done, restart the program on this computer, then on the other computers.");
            try{
                Process.Start(destinationPath);
                Application.Exit();
            }catch {
                MsgBox.Show(FormP, "Could not launch setup");
            }
        }
Exemplo n.º 7
0
 private void CreateLoLRecordPlayer()
 {
     this._recordPlayer = new LoLRecordPlayer(this._record);
     System.Threading.ThreadStart start = new System.Threading.ThreadStart(this._recordPlayer.startPlaying);
     this._playerThread = new System.Threading.Thread(start);
     this._playerThread.Start();
 }
Exemplo n.º 8
0
        public string SendMail(MAILINFO ob, bool bThread = true)
        {
            string msg = string.Empty;

            try
            {
                obMail   = ob;
                _bThread = bThread;
                if (bThread)
                {
                    ThreadStart1 = new System.Threading.ThreadStart(this.SendMailExec);
                    thread1      = new Thread(ThreadStart1);
                    thread1.Start();
                }
                else
                {
                    this.SendMailExec();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(msg);
        }
Exemplo n.º 9
0
        private void NewMethod()
        {
            // This server generates a new connection for each client
            while (true)
            {
                TcpClient client = listener.AcceptTcpClient();

                // waiting for client that wants to connect and accept it
                client = listener.AcceptTcpClient();
                //  try
                {
                    Console.WriteLine("Client connected");
                    // handle this client (seperate thread)
                    IClientHandler currClientHandler = new IClientHandler(client);
                    currClientHandler.userConnected    += CurrClientHandler_userConnected;
                    currClientHandler.userDisconnected += CurrClientHandler_userDisconnected;
                    currClientHandler.userSentMessage  += CurrClientHandler_userSentMessage;
                    System.Threading.ThreadStart ts = new System.Threading.ThreadStart(currClientHandler.HandleClient);
                    System.Threading.Thread      t  = new System.Threading.Thread(ts);
                    t.Start();
                }
                //    catch (Exception ex)
                //    {
                //        Console.WriteLine(ex.Message);
                //   }
            }
        }
        private void AsyncQueueJobHandler(AsyncQueueBCPJobArgs args)
        {
            if (this.InvokeRequired)
            {
                AsyncQueueBCPJob queueJobHandler = new AsyncQueueBCPJob(AsyncQueueJobHandler);
                this.Invoke(queueJobHandler, new object[] { args });
            }
            else
            {
                BCPJobs.Add(args.JobInfo);
                if (_ThreadManager == null)
                {
                    int threadCount = Convert.ToInt32(ConfigurationManager.AppSettings["NumberOfBCPThreads"]);
                    _ta       = new Thread[threadCount];
                    _tabPages = new TabPage[threadCount];

                    for (int index = 0; index < _ta.Count(); index++)
                    {
                        _tabPages[index] = AddTab();
                    }

                    ThreadStart ts = new System.Threading.ThreadStart(ThreadManager);
                    _ThreadManager = new System.Threading.Thread(ts);
                    _ThreadManager.CurrentCulture   = CultureInfo.CurrentCulture;
                    _ThreadManager.CurrentUICulture = CultureInfo.CurrentUICulture;
                    _ThreadManager.Start();
                }
            }
        }
Exemplo n.º 11
0
        static void Main()
        {
            Thread.CurrentThread.Name = "Main";
            Console.WriteLine("[Main] Starting program. Total funds on deposit would always be");

            for (int n = 0; n < SimulationParameters.NUMBER_OF_ACCOUNTS; n++)
            {
                s_bankAccounts[n] = new BankAccount(n, SimulationParameters.INITIAL_DEPOSIT);
            }

            Thread[] transferThreads = new Thread[SimulationParameters.NUMBER_OF_TRANSFER_THREADS];
            System.Threading.ThreadStart threadProc = new System.Threading.ThreadStart(TransferThreadProc);

            for (int n = 0; n < SimulationParameters.NUMBER_OF_TRANSFER_THREADS; n++)
            {
                transferThreads[n]      = new Thread(threadProc);
                transferThreads[n].Name = string.Format("X-{0}", n);
                transferThreads[n].Start();
            }
            Thread.Sleep((SimulationParameters.SIMULATION_LENGTH));
            Console.WriteLine("[Main] shutting down simulation");
            s_simulationOver = true;

            for (int n = 0; n < transferThreads.Length; n++)
            {
                transferThreads[n].Join();
            }

            Console.WriteLine("[Main] Simulation comlete, verifying accounts.");

            VerifyAccounts();
        }
Exemplo n.º 12
0
 public void Dispose()
 {
     System.Threading.ThreadStart threadStart = System.Threading.Interlocked.Exchange <System.Threading.ThreadStart>(ref this.callback, null);
     if (threadStart != null)
     {
         threadStart();
     }
 }
Exemplo n.º 13
0
 public CallbackOnDispose(System.Threading.ThreadStart callback)
 {
     if (callback == null)
     {
         throw new ArgumentNullException("callback");
     }
     this.callback = callback;
 }
Exemplo n.º 14
0
 public void Dispose()
 {
     System.Threading.ThreadStart action = Interlocked.Exchange(ref callback, null);
     if (action != null)
     {
         action();
     }
 }
Exemplo n.º 15
0
        public static IAsyncResult BeginInvoke(System.Threading.ThreadStart dlgt, AsyncCallback asyncCallback, object state)
        {
            AsyncNoResult <ThreadStart> ar = new AsyncNoResult <ThreadStart>(
                asyncCallback, state, dlgt);

            ThreadPool.QueueUserWorkItem(_RunnerNoResult, ar);
            return(ar);
        }
Exemplo n.º 16
0
 /// <summary>
 /// 开始发送文件的监听线程
 /// </summary>
 void StartListener()
 {
     System.Threading.ThreadStart ts = ListenForSendRequest;
     new System.Threading.Thread(ts)
     {
         IsBackground = true
     }.Start();
 }
Exemplo n.º 17
0
 public CAudioPlayer()
 {
     _init();
     _effects = new BlockingCollection <CSound>();
     System.Threading.ThreadStart threadStarter = _checkForThingsToPlay;
     _audioThread = new Thread(threadStarter);
     _audioThread.Start();
 }
Exemplo n.º 18
0
 private void ToolStripMenuItemexportarBaseDeConocimiento_Click(object sender, EventArgs e)
 {
     ventana_configuracion.Visible           = false;
     ventana_gestion_de_conocimiento.Visible = false;
     ventana_cargando.Show();
     System.Threading.ThreadStart metodo = new System.Threading.ThreadStart(exportar);
     metodo.Invoke();
 }
Exemplo n.º 19
0
 public static System.Threading.Thread StartThread(System.Threading.ThreadStart start, bool isBackground)
 {
     System.Threading.Thread thread = new System.Threading.Thread(start);
     thread.IsBackground   = isBackground;
     thread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
     thread.Start();
     return(thread);
 }
Exemplo n.º 20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //this.sshClient = new SshClient();
            System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(recvSSHData);
            System.Threading.Thread      thread      = new System.Threading.Thread(threadStart);

            thread.IsBackground = true;
            thread.Start();
        }
Exemplo n.º 21
0
        private void TimerComputerShutdown_Load(object sender, System.EventArgs e)
        {
            this.threadStart = new System.Threading.ThreadStart(Application_Tick);
            this.thread      = new System.Threading.Thread(threadStart);

            this.panelChild.Visible = false;

            this.dateTimePicker.Value = System.DateTime.Now;
        }
Exemplo n.º 22
0
 public WebSocket(Socket socket)
 {
     client = socket;
     System.Threading.ThreadStart ts;
     ts            = new System.Threading.ThreadStart(ListenSocket);
     _clientThread = new System.Threading.Thread(ts);
     _clientThread.Start();
     onmessage = GameChoose;
 }
Exemplo n.º 23
0
 public WebSocket(Socket socket)
 {
     client = socket;
     System.Threading.ThreadStart ts;
     ts = new System.Threading.ThreadStart(ListenSocket);
     _clientThread = new System.Threading.Thread(ts);
     _clientThread.Start();
     onmessage = GameChoose;
 }
Exemplo n.º 24
0
        public void Start()
        {
            watch.Restart();
            var ts = new System.Threading.ThreadStart(TimerProcess);
            var t  = new System.Threading.Thread(ts);

            t.IsBackground = true;
            t.Start();
        }
        /// <summary>
        /// 初始化Tcp监听
        /// </summary>
        public void TcpInit()
        {
            listenPort += new ThreadStart(TcpStartListen);
            lister      = new Thread(listenPort);

            tcpLister = new TcpListener(Dns.GetHostAddresses(Dns.GetHostName())[0], SocketPort);

            client = new TcpClient(SocketHomeIP, SocketPort);
        }
Exemplo n.º 26
0
 public static void Main(string[] args)
 {
     for (int i = 0; i < 300; ++i)
     {
         System.Threading.ThreadStart y = new System.Threading.ThreadStart(performOperation);
         System.Threading.Thread      x = new System.Threading.Thread(y);
         x.Start();
     }
 }
        public void ThreadManager()
        {
            AsyncTabPageEventArgs args = new AsyncTabPageEventArgs(0, "");

            while (true)
            {
                for (int index = 0; index < _ta.Count(); index++)
                {
                    args.CurrentTabIndex = index;
                    if (_ta[index] != null)
                    {
                        if (_ta[index].ThreadState == System.Threading.ThreadState.Stopped)
                        {
                            BCPCommandCtrl par = (BCPCommandCtrl)_tabPages[index].Controls[0];
                            if (par.CurrentJobInfo.JobStatus == CommandStatus.Success || par.CurrentJobInfo.JobStatus == CommandStatus.Skip)
                            {
                                args.Show = false;
                                UpdateTabHandler(args);
                                _ta[index] = null;
                            }
                        }
                    }

                    args.Show = true;

                    if (_ta[index] == null)
                    {
                        BCPJobInfo jobInfo = GetNextWaitingJob();
                        if (jobInfo != null)
                        {
                            args.DisplayText           = jobInfo.TableName;
                            args.CurrentTabIndex       = index;
                            jobInfo.CurrentThreadIndex = index;

                            UpdateTabHandler(args);

                            BCPCommandCtrl par = (BCPCommandCtrl)_tabPages[index].Controls[0];
                            par.CurrentJobInfo = jobInfo;

                            ThreadStart ts = new System.Threading.ThreadStart(delegate() { StartUpload(par); });
                            _ta[index] = new Thread(ts);
                            _ta[index].CurrentCulture   = CultureInfo.CurrentCulture;
                            _ta[index].CurrentUICulture = CultureInfo.CurrentUICulture;
                            _ta[index].Start();
                        }
                    }
                }
                Thread.Sleep(500);    // Sleep for awhile and then look for more data to process
                if (AsyncProcessingStatus.FinishedAddingJobs && BCPJobsDone())
                {
                    break;
                }
            }
            args.RemoveTabs = true;
            UpdateTabHandler(args);
            AsyncProcessingStatus.FinishedProcessingJobs = true;
        }
Exemplo n.º 28
0
 /// <summary>
 /// invoke the statistics updater
 /// </summary>
 public void UpdateStats()
 {
     if (statistics.InvokeRequired)
     {
         System.Threading.ThreadStart up = new System.Threading.ThreadStart(DumpStats);
         statistics.Invoke(up);
     }
     else
         DumpStats();
 }
Exemplo n.º 29
0
 /// <summary>
 /// invoke the TCP datagridview updater
 /// </summary>
 public void UpdateTCP()
 {
     if (tcpDisplay.InvokeRequired)
     {
         System.Threading.ThreadStart up = new System.Threading.ThreadStart(TCPUpdate);
         tcpDisplay.Invoke(up);
     }
     else
         TCPUpdate();
 }
Exemplo n.º 30
0
        void TimeThis(out int ticks, System.Threading.ThreadStart code)
        {
            int start = Environment.TickCount;

            try {
                code();
            } finally {
                ticks = Environment.TickCount - start;
            }
        }
        private void btnRetry_Click(object sender, EventArgs e)
        {
            BCPCommandCtrl par     = (BCPCommandCtrl)tabCtlUploadStatus.TabPages[tabCtlUploadStatus.SelectedIndex].Controls[0];
            BCPJobInfo     jobInfo = par.CurrentJobInfo;

            ThreadStart ts = new System.Threading.ThreadStart(delegate() { StartUpload(par); });

            _ta[par.CurrentJobInfo.CurrentThreadIndex] = new Thread(ts);
            _ta[par.CurrentJobInfo.CurrentThreadIndex].Start();
        }
Exemplo n.º 32
0
        private void Main_Load(object sender, EventArgs e)
        {
            System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(recvSSHData);
            System.Threading.Thread      thread      = new System.Threading.Thread(threadStart);
            findOT2IP();
            thread.IsBackground = true;
            thread.Start();

            btnRotate.Enabled  = false;
            menuStrip1.Enabled = true;
        }
Exemplo n.º 33
0
 /// <summary>
 /// invoke the statistics updater
 /// </summary>
 public void UpdateStats()
 {
     if (statistics.InvokeRequired)
     {
         System.Threading.ThreadStart up = new System.Threading.ThreadStart(DumpStats);
         statistics.Invoke(up);
     }
     else
     {
         DumpStats();
     }
 }
Exemplo n.º 34
0
        public MavenRunner(DTE2 dte2)
        {
            this.dte2 = dte2;
            output = MakeOutputWindow();
            outputThreadEvent = null;

            // create a worker thread for outputing the process console out puts
            running = true;
            System.Threading.ThreadStart outputThreadStart = new System.Threading.ThreadStart(OutputThreadDelegate);
            outputThread = new System.Threading.Thread(outputThreadStart);
            outputThread.Start();

            // create a separate worker thread for outputing the Process.StandardError
            System.Threading.ThreadStart outputErrorThreadStart = new System.Threading.ThreadStart(OutputErrorThreadDelegate);
            outputErrorThread = new System.Threading.Thread(outputErrorThreadStart);
            outputErrorThread.Start();
        }
Exemplo n.º 35
0
        public void RevokeLifetimeToken(int token)
        {

            lock (m_lifetimeTokens)
            {
                if (!m_lifetimeTokens.Remove(token))
                    throw new InvalidOperationException(Res.LifetimeTokenNotFound);

                if (m_lifetimeTokens.Count == 0)
                {
                    m_zeroReferencesLeft = true;
                    // hook to allow subclasses to clean up
                    OnFinalRevoke();

                    IContract owner = ContractHandle.AppDomainOwner(AppDomain.CurrentDomain);
                    if (owner != null)
                    {
                        if (owner == this)
                        {
                            // Create a separate thread to unload this appdomain, because we 
                            // cannot shut down an appdomain from the Finalizer thread (though there
                            // is a bug that allows us to do so after the first appdomain has been
                            // unloaded, but let's not rely on that).  
                            // We can consider using an threadpool thread to do this, but that would add
                            // test burden.

                            SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.ControlThread);
                            permission.Assert();

                            System.Threading.ThreadStart threadDelegate = new System.Threading.ThreadStart(AppDomainUnload);
                            System.Threading.Thread unloaderThread = new System.Threading.Thread(threadDelegate);
                            unloaderThread.Start();
                        }
                        else
                            owner.RevokeLifetimeToken(m_tokenOfAppdomainOwner);
                    }
                }
            }
        }
Exemplo n.º 36
0
 public static void StartAgent()
 {
     SchedulerConfiguration config = new SchedulerConfiguration(1000 * 60);//设置时间,此处为1分钟
     config.Jobs.Add(new AlertJob());
     Scheduler scheduler = new Scheduler(config);
     System.Threading.ThreadStart myThreadStart = new System.Threading.ThreadStart(scheduler.Start);
     schedulerThread = new System.Threading.Thread(myThreadStart);
     schedulerThread.Start();
 }
Exemplo n.º 37
0
 public CallbackOnDispose(System.Threading.ThreadStart callback)
 {
     if (callback == null)
         throw new ArgumentNullException("callback");
     this.callback = callback;
 }
Exemplo n.º 38
0
 /// <summary>
 /// Starts thread with listening socket.
 /// </summary>
 public static void Start()
 {
     System.Threading.ThreadStart ts = new System.Threading.ThreadStart(Listen);
     _serverThread = new System.Threading.Thread(ts);
     _serverThread.Start();
 }
Exemplo n.º 39
0
 public void boot_func( )
 {
     System.Threading.ThreadStart ts = new System.Threading.ThreadStart(boot);
     threadProg = new System.Threading.Thread(ts);
     threadProg.IsBackground = true;
     threadProg.Priority = ThreadPriority.Highest;
     threadProg.Start();
 }
Exemplo n.º 40
0
        public void ExecuteScript(string script, bool syntaxCheckOnly, uint[] parameters)
        {
            // kill current syntax check in progress (if any is running)
            if (this.IsGGenRunning() && mode == Mode.SyntaxCheck && syntaxCheckOnly == false)
            {
                // wait for the syntax check to finish (it usually takes just milliseconds)
                this.GGenThread.Join();

                // do the check one the requested script is finished
                this.ScheduleSyntaxCheck();
            }
            // syntax checks are not allowed while a script is being executed
            else if (this.IsGGenRunning() && syntaxCheckOnly == true)
            {
                // do the check one the requested script is finished
                if(!this.isCheckScheduled) this.ScheduleSyntaxCheck();

                return;
            }
            // having two generators running at once shouldn't happen
            else if (this.IsGGenRunning() && mode == Mode.Standard)
            {
                throw new Exception("Two GeoGens can't possibly be running at one time");
            }

            if (!syntaxCheckOnly)
            {
                this.mode = Mode.Standard;
                this.ButtonsRunMode();
                this.AddStatus("Executing");

                this.ClearData();

                this.WriteToConsole("Starting at " + DateTime.Now.ToString("HH:mm:ss") + "...");
            }
            else{
                this.mode = Mode.SyntaxCheck;
                
                this.lastCheckContent = "";
                this.AddStatus("Checking syntax");
            }

            System.Threading.ThreadStart starter = new System.Threading.ThreadStart(delegate
            {
                try
                {
                    try
                    {
                        ggen.SetScript(script);
                    }
                    catch (SyntaxErrorException)
                    {
                        this.MapGenerationFailed("Compilation failed!");

                        return;
                    }

                    try
                    {
                        ggen.LoadArgs();
                    }
                    catch (ArgsUnreadableException)
                    {
                        this.MapGenerationFailed("Map header is unreadable!");

                        return;
                    }

                    // do not generate the map during syntax check runs
                    if (!syntaxCheckOnly)
                    {
                        // no list of arguments was passed to the function -> use params from the param table
                        if (parameters == null)
                        {
                            var zipped = this.parameters.Item.Cast<PropertyGridEx.CustomProperty>().Zip(ggen.Args, (Property, Arg) => new { Property, Arg });

                            foreach (var item in zipped)
                            {
                                // fill in only matching arguments
                                if (item.Property.Type.Name == "Boolean" && item.Arg.Type == ScriptArgType.Bool)
                                {
                                    item.Arg.Value = (uint)item.Property.Value;
                                }

                                else if (item.Property.Type.Name == "UInt32" && item.Arg.Type == ScriptArgType.Int)
                                {
                                    item.Arg.Value = (uint)item.Property.Value;
                                }
                                else if (item.Property.Type.Name == "Int32" && item.Arg.Type == ScriptArgType.Int)
                                {
                                    item.Arg.Value = (uint)((int)item.Property.Value);
                                }
                                else if (item.Property.Type.Name == "String" && item.Arg.Type == ScriptArgType.Enum)
                                {
                                    item.Arg.Value = (uint)item.Property.Choices.IndexOf(item.Property.Value);
                                }
                            }

                            /*int i = 0;
                            foreach (PropertyGridEx.CustomProperty property in this.parameters.Item)
                            {
                                
                                
                                Generator.ScriptArg arg = ggen.Args[i];

                                // we ran out of parameters...
                                if (i == ggen.Args.Count())
                                {
                                    break;
                                }

                                // fill in only matching arguments
                                if (property.Type.Name == "Boolean" && arg.Type == ScriptArgType.Bool)
                                {
                                    arg.Value = (uint)property.Value;
                                }

                                else if (property.Type.Name == "UInt32" && arg.Type == ScriptArgType.Int)
                                {
                                    arg.Value = (uint)property.Value;
                                }
                                else if (property.Type.Name == "Int32" && arg.Type == ScriptArgType.Int)
                                {
                                    arg.Value = (uint)((int)property.Value);
                                }
                                else if (property.Type.Name == "String" && arg.Type == ScriptArgType.Enum)
                                {
                                    arg.Value = (uint)property.Choices.IndexOf(property.Value);
                                }

                                i++;
                            }*/
                        }
                        // the argument list was passed to the function
                        else
                        {
                            var zipped = parameters.Zip(ggen.Args, (Param, Arg) => new { Param, Arg });

                            foreach (var item in zipped)
                            {
                                item.Arg.Value = item.Param;
                            }

                            /*int i = 0;
                            foreach (uint currentParam in parameters)
                            {
                                Generator.ScriptArg arg = ggen.Args[i];

                                // we ran out of parameters...
                                if (i == ggen.Args.Length)
                                {
                                    break;
                                }

                                arg.Value = currentParam;

                                i++;
                            }*/
                        }

                        this.startTime = System.DateTime.Now.Ticks / 10000;

                        HeightData result;
                        try
                        {
                            if (this.config.seed == 0)
                            {
                                ggen.Seed = (uint)DateTime.Now.Ticks;
                            }
                            else
                            {
                                ggen.Seed = this.config.seed;
                            }

                            result = ggen.Generate();
                        }
                        catch (GenerationFailedException)
                        {
                            this.MapGenerationFailed("Map generation failed!");

                            return;
                        }
                        catch (ExceptionInCallbackException e)
                        {
                            // the thread was aborted
                            if (e.InnerException is ThreadAbortException)
                            {
                                this.ggen.Reset();
                                this.BeginInvoke(new MethodInvoker(delegate()
                                {
                                    this.MapGenerationFailed("Aborted!");
                                }));
                                return;
                            }

                            // else unknown exception, we want to debug this case
                            throw;
                        }

                        // map was generated successfully
                        HeightData result2 = Main.GetResizedHeightData(result, Math.Min(result.Width, (int)config.mapDetailLevel), Math.Min(result.Height, (int)config.mapDetailLevel));

                        result.Dispose();

                        Main.StretchHeightValues(ref result2);

                        maps.Add("[Main]", result2);

                        this.RemoveStatus("Executing");

                        this.Invoke(new MethodInvoker(delegate()
                        {
                            // was this part of a benchmark?
                            if (benchmarkStatus != null)
                            {
                                this.Benchmark();

                                return;
                            }

                            this.ReloadMaps(null);

                            this.WriteToConsole("Finished after " + Math.Round((System.DateTime.Now.Ticks / 10000 - this.startTime) / 1000d, 3) + " seconds!" + Environment.NewLine);

                            this.ButtonsNoRunMode();                            
                        }));
                    }
                    else
                    {
                        this.Invoke(new MethodInvoker(delegate()
                        {
                            this.RebuildArgsTable();
                            this.SetErrorStatus(false);
                        }));
                    }
                }
                catch (InternalErrorException e)
                {
                    this.WriteToConsole("Error: " + e.InnerException.Message);
                    this.MapGenerationFailed("GeoGen has unexpectedly crashed!");
                }
                finally
                {
                    this.BeginInvoke(new MethodInvoker(delegate()
                    {
                        this.RemoveStatus("Executing");
                        this.RemoveStatus("Checking syntax");
                        this.ExecuteScheduledCheck();
                    }));
                }
            });

            GGenThread = new System.Threading.Thread(starter);

            GGenThread.Start();
        }
Exemplo n.º 41
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (m_workerQueue.IsSynchronized)
     {
         if (m_workerQueue.Count > 0)
         {
             //MessageBox.Show("Haha!!!");
             ThreadStart job;
             Thread thread;
             for (int i = 0; i < 3; i++)
             {
                 string a = ThreadArray[i].ToString().Trim();
                 WriteLogPri(ThreadArray[i].ToString().Trim());
                 if (ThreadArray[i].ToString().Trim() == "-")
                 {
                     job = new System.Threading.ThreadStart(DoProcess);
                     thread = new System.Threading.Thread(job);
                     ThreadArray[i] = thread;
                     ((Thread)ThreadArray[i]).Start();
                     break;
                 }
                 else if (((Thread)ThreadArray[i]).ThreadState.ToString().Trim() != "Running")
                 {
                     ((Thread)ThreadArray[i]).Abort();
                     ThreadArray[i] = null;
                     job = new System.Threading.ThreadStart(DoProcess);
                     thread = new System.Threading.Thread(job);
                     ThreadArray[i] = thread;
                     ((Thread)ThreadArray[i]).Start();
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 42
0
        private void TimerComputerShutdown_Load(object sender, System.EventArgs e)
        {
            this.threadStart = new System.Threading.ThreadStart(Application_Tick);
            this.thread = new System.Threading.Thread(threadStart);

            this.panelChild.Visible = false;

            this.dateTimePicker.Value = System.DateTime.Now;
        }
Exemplo n.º 43
0
 /// <summary>
 /// Initializes a new instance of the SThread class.
 /// </summary>
 /// <param name="Start">A ThreadStart delegate that references the methods to be invoked when this SThread begins executing</param>
 /// <param name="Name">The name of the SThread</param>
 public Thread(ThreadStart task, System.String Name)
 {
     runnable0 = task;
     MakeThis(true);
     this.Name = Name;
 }
 public void upload()
 {
     if (!isUploading)
     {
         isUploading = true;
         try
         {
             System.Threading.ThreadStart start = new System.Threading.ThreadStart(this.BeginUpload);
             new System.Threading.Thread(start).Start();
         }
         catch (System.Exception exception)
         {
             LogMessage("Swallowing exception: " + exception.Message);
         }
     }
 }
Exemplo n.º 45
0
 /// <summary>
 /// invoke the UDP datagridview updater
 /// </summary>
 public void UpdateUDP()
 {
     if (udpDisplay.InvokeRequired)
     {
         System.Threading.ThreadStart up = new System.Threading.ThreadStart(UDPUpdate);
         udpDisplay.Invoke(up);
     }
     else
         UDPUpdate();
 }
Exemplo n.º 46
0
 public Thread(ThreadStart task, int size)
 {
     this.size = size;
     runnable0 = task;
     MakeThis(true);
 }
Exemplo n.º 47
0
 /// <summary>
 /// Initializes a new instance of the Thread class.
 /// </summary>
 /// <param name="task">A ThreadStart delegate that references the methods to be invoked when this SThread begins executing</param>
 public Thread(ThreadStart task)
 {
     runnable0 = task;
     MakeThis(true);
 }
Exemplo n.º 48
0
 public void verify_func()
 {
     System.Threading.ThreadStart ts = new System.Threading.ThreadStart(verify);
     threadVerify = new System.Threading.Thread(ts);
     threadVerify.IsBackground = true;
     threadVerify.Priority = ThreadPriority.Highest;
     threadVerify.Start();
 }
Exemplo n.º 49
0
 public IEnumerator waitForInitializeFinish()
 {
     UnityEngine.Application.ExternalEval("DebugPrint(\"Things work! (wait for init)\");" );
     System.Threading.ThreadStart start = new System.Threading.ThreadStart(Initialize_imp);
     System.Threading.Thread t = new System.Threading.Thread(start);
     t.Start();
     while( t.IsAlive ){
         yield return new WaitForSeconds(0.5f);
         UnityEngine.Application.ExternalEval("DebugPrint(\"Things work! (waiting...)\");" );
     }
     UnityEngine.Application.ExternalEval("DebugPrint(\"Things work! (done)\");" );
     GameObject.Find(ObjectName).BroadcastMessage("Scorm_Initialize_Complete",SendMessageOptions.DontRequireReceiver);
 }
Exemplo n.º 50
0
 public void doPushThread(int how)
 {
     this.pthow = how;
     System.Threading.ThreadStart mt = new System.Threading.ThreadStart(doPush);
     System.Threading.Thread thread1 = new System.Threading.Thread( mt ) ;
     Form1.debugMessage("Starting doPush (" + pthow + ") Thread...");
     thread1.Start() ;
     Form1.debugMessage("... Done Starting doPush (" + pthow + ")Thread.");
 }