Makes starting a method in a seperated thread just a little bit easier.
Ejemplo n.º 1
0
        public ServiceCharting(ref ForexService ForexService) : base(ref ForexService)
        {
            ThreadsUpdate = new ThreadedMethod(25, System.Threading.ThreadPriority.Lowest, 1);
            ThreadsSave   = new ThreadedMethod(25, System.Threading.ThreadPriority.Lowest, 1);

            Timers.Run(() => this.UpdateTimer(), 1000, null, true, false);
        }
Ejemplo n.º 2
0
 public void EnqueueOutgoingTask(ThreadedMethod task)
 {
     lock (this.mOutgoingTasksQueue)
     {
         this.mOutgoingTasksQueue.Enqueue(task);
     }
 }
Ejemplo n.º 3
0
 public void EnqueueIncomingTask(ThreadedMethod task)
 {
     lock (this.mIncomingTasksQueue)
     {
         this.mIncomingTasksQueue.Enqueue(task);
     }
 }
Ejemplo n.º 4
0
        public Archive()
        {
            ThreadsLoad = new ThreadedMethod(25, System.Threading.ThreadPriority.Highest, 1);
            ThreadsMain = new ThreadedMethod(25, System.Threading.ThreadPriority.Highest, 1);
            ThreadsSave = new ThreadedMethod(25, System.Threading.ThreadPriority.Normal, 1);

            //FileDictionary<TickTime, DealRequest> IODictionary = new FileDictionary<TickTime, DealRequest>(@"C:\k.k", -10);
            //DateTime nnn = (DateTime)IODictionary.Data.First().Value.CreationTime; if (nnn == DateTime.Now) return;
            //StopWatch.Run("IO");
            //for (int i = 0; i < 1000; i++)
            //{
            //    DealRequest DR = new DealRequest();
            //    DR.ASK = 1;
            //    DR.BID = -1;
            //    DR.TFBuySell = true;
            //    DR.CreationTime = (TickTime)TickTime.Now;
            //    IODictionary.Add(DR.CreationTime, DR);


            //    //
            //}
            //double msss = StopWatch.ms("IO");
            //IODictionary.SaveData();
            //if (msss > 100000000)
            //    Asmodat.Foo.nop();

            ThreadsMain.Run(() => this.LoadAll(), null, true, true);
        }
Ejemplo n.º 5
0
 public AbstractServices(ref ForexService ForexService)
 {
     this.ForexService = ForexService;
     Timers            = new ThreadedTimers(100);
     Threads           = new ThreadedMethod(100);
     Locks             = new ThreadedLocker(100);
     Exceptions        = new ThreadedBuffer <Exception>(100);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Event: The login button has been clicked
        /// </summary>
        private void Button_Login_Click(object sender, EventArgs e)
        {
            // Diable constrols and show message
            Label_Status.Visible = true;
            Label_Status.Text    = "Logging in...";
            SetControlsEnabled(false);

            ThreadedMethod tMethod = new ThreadedMethod(login);

            tMethod.Start();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Event: The 'Add this account' button has been clicked.
        /// </summary>
        private void Button_AddThisAccount_Click(object sender, EventArgs e)
        {
            // Disable controls
            SetControlsEnabled(false);

            // Show 'please wait' message
            Label_Status.Visible = true;

            // Start verifyAccount() in a new thread
            ThreadedMethod tMethod = new ThreadedMethod(verifyAccount);

            tMethod.Start();
        }
Ejemplo n.º 8
0
        private void InitRequestManager()
        {
            FileDealRequest = new File("DealRequest", true);
            ThreadRequest   = new ThreadedMethod(100, System.Threading.ThreadPriority.Highest, 1);
            DataDealRequest = new ThreadedDictionary <TickTime, DealRequest>();

            string data = FileDealRequest.Load();

            if (System.String.IsNullOrEmpty(data))
            {
                return;
            }

            DataDealRequest.XmlDeserialize(data);
        }
Ejemplo n.º 9
0
        public void StopAll()
        {
            Method.Terminate("main");


            var keys = D2Sockets.Keys;

            try
            {
                ThreadedMethod methods = new ThreadedMethod(keys.Length);

                foreach (string key in keys)
                {
                    methods.Run(() => this.Stop(key), "stop" + key, true, false);
                }

                methods.JoinAll();
            }
            finally
            {
                Method.Terminate(() => StartListening());
            }
        }
        /// <summary>
        /// Event: The login button has been clicked
        /// </summary>
        private void Button_Login_Click(object sender, EventArgs e)
        {
            // Diable constrols and show message
            Label_Status.Visible = true;
            Label_Status.Text = "Logging in...";
            SetControlsEnabled(false);

            ThreadedMethod tMethod = new ThreadedMethod(login);
            tMethod.Start();
        }
        /// <summary>
        /// Event: The 'Add this account' button has been clicked.
        /// </summary>
        private void Button_AddThisAccount_Click(object sender, EventArgs e)
        {
            // Disable controls
            SetControlsEnabled(false);

            // Show 'please wait' message
            Label_Status.Visible = true;

            // Start verifyAccount() in a new thread
            ThreadedMethod tMethod = new ThreadedMethod(verifyAccount);
            tMethod.Start();
        }
 private void TextBox_ContactsName_TextChanged(object sender, EventArgs e)
 {
     ThreadedMethod tMethod = new ThreadedMethod(UpdateContactName);
     tMethod.Start();
 }
Ejemplo n.º 13
0
 private void mTimerSync_Tick(object sender, EventArgs e)
 {
     ThreadedMethod[] tasks = new ThreadedMethod[0];
     lock (this.mOutgoingTasksQueue)
     {
         tasks = this.mOutgoingTasksQueue.ToArray();
         this.mOutgoingTasksQueue.Clear();
     }
     foreach (ThreadedMethod task in tasks)
     {
         if (task != null)
             task();
     }
 }
        private void TextBox_ContactsName_TextChanged(object sender, EventArgs e)
        {
            ThreadedMethod tMethod = new ThreadedMethod(UpdateContactName);

            tMethod.Start();
        }