Esempio n. 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var icoStream = TryLoadIcon();

            if (icoStream is null)
            {
                MessageBox.Show("Can't load icon");
                Application.Exit();
                return;
            }

            LoadTitles();

            var icon = new TrayIcon();

            icon.Init(icoStream);
            icon.AddMenuItem("E&xit", Stop);

            icon.Show();

            _timer = new System.Threading.Timer(o => TrySetTotalCommanderTitle(), null, 0, 1000);

            Application.Run();
        }
Esempio n. 2
0
        public Form1()
        {
            int k;

            InitializeComponent();

            if (!MessageQueue.Exists(@".\private$\myMSMQ"))
            {
                MessageQueue.Create(@".\private$\myMSMQ");
            }

            proxy = new TTProxy();
            DataTable users = proxy.GetPeopleByRole("solver");

            for (k = 0; k < users.Rows.Count; k++)
            {
                listBox1.Items.Add(users.Rows[k][1]);   // Row 0 is empty; the author name is in column 1
            }
            DataTable unassigned_tickets = proxy.GetUnassignedTickets();

            dataGridView1.DataSource = unassigned_tickets;

            DateTime start = DateTime.Now;

            timer = new Timer(_ => UpdateTickets(start), null, 1000, 500);
        }
        public void Start(int MaxThreadCount, int minThreadCount = _DefaultMinThreadCount)
        {
            lock (m_SyncRoot)
            {
                if (m_Disposed)
                {
                    throw new ObjectDisposedException(GetType().FullName);
                }

                if (m_Started)
                {
                    throw new InvalidOperationException("SmartThreadPool already started.");
                }

                STPStartInfo startInfo = new STPStartInfo();
                startInfo.MinWorkerThreads = minThreadCount;
                startInfo.MaxWorkerThreads = MaxThreadCount;
                startInfo.IdleTimeout      = 20000; // After 20 seconds, a thread counts as an idle one
                startInfo.EnableLocalPerformanceCounters = true;
                startInfo.ThreadPoolName = "Smart Threadpool";
                m_SmartThreadPool        = new SmartThreadPool(startInfo);
                m_SmartThreadPool.Start();
                statisticsTimer = new Timer(new TimerCallback(StatisticsTimer), null, 5000, 120000);
                m_Started       = true;
            }
        }
Esempio n. 4
0
 private void tbFilter_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (filterTimer != null)
     {
         filterTimer.Dispose();
     }
     filterTimer = new System.Threading.Timer(new TimerCallback(PerformFiltering), null, filterDelay, Timeout.Infinite);
 }
Esempio n. 5
0
 private void timercallback(object value)
 {
     //disable timer..
     Debug.Print("timercallback");
     delaytimer.Dispose();
     delaytimer = null;
     //invoke the routine to initialize the game state...
     if (!ShownAsAbout)
     {
         quickthread = new Thread(threadinitroutine);
         quickthread.Start();
     }
     bobberthread = new Thread(BobberThread);
     bobberthread.Start();
 }
 private async void SecondTimer(object obj)
 {
     SecondCount--;
     if ((SecondCount < 60) && (SecondCount > 0))
     {
         string text = SecondCount + " " + (SecondCount == 1 ? "second" : "seconds");
         await WrapGuiAction(() => labUpdateTime.Text = text);
     }
     else if (SecondCount >= 60)
     {
         int    val  = (SecondCount + 30) / 60;
         string text = val + " " + (val == 1 ? "minute" : "minutes");
         await WrapGuiAction(() => labUpdateTime.Text = text);
     }
     else
     {
         secondtimer.Dispose();
         secondtimer = null;
         await RefreshUpdates();
     }
 }
 private void SetStopState()
 {
     playedsound.Stop();
     cmdPlayStop.Invoke((MethodInvoker)(() => { cmdPlayStop.Text = "&Play"; }));
     if (PositionUpdateTimer != null)
     {
         PositionUpdateTimer.Dispose();
         PositionUpdateTimer = null;
     }
     playedsound = null;
     playingsound = null;
     //File.Delete(mTempFilename);
     BCBlockGameState.QueueDelete(mTempFilename);
     mTempFilename = "";
 }
Esempio n. 8
0
 private void StopTickler()
 {
     this.Tickler.Change(Timeout.Infinite, Timeout.Infinite);
     this.Tickler.Dispose();
     this.tickler = null;
 }
Esempio n. 9
0
        private void SplashScreen_Load(object sender, EventArgs e)
        {
            //431, 260
            createregunregimage();
            chooseimage();
            this.AllowTransparency = true;
            //first, initialize image panel to 431, 260
            panImage.Location = new Point(0, 0);
            //change this if the image is changed...
            Size UseSize = new Size(431, 260);
            PointF ScaleValue = DPIHelper.GetDPIScaling(this);
            UseSize = new Size((int)((float)UseSize.Width*ScaleValue.X),(int)((float)UseSize.Height*ScaleValue.Y));

            panImage.Size = UseSize;
            Size = new Size(panImage.Width, panImage.Height + panProgress.Height);
            //clear the background of the panImage to speed drawing
            //panImage.BackgroundImage=null;

            InitBackground();
            //ImageBackBufferCanvas.DrawImage(useBackground, 0, 0, BackgroundBitmap.Width, BackgroundBitmap.Height);
            //move the lower pane...
            panProgress.Location = new Point(0, panImage.Bottom);
            panProgress.Size = new Size(panImage.Width, ClientSize.Height - panImage.Bottom);
            panProgress.Visible = !ShownAsAbout;
            PanelAbout.Visible = ShownAsAbout;
            PanelAbout.Size = panProgress.Size;
            if (ShownAsAbout)
            {
                LowerPanel = PanelAbout;
                PanelAbout.Visible = true;
            }
            else
            {
                LowerPanel = panProgress;
            }
            LowerPanel.Visible = true;

            LowerPanel.Location = new Point(0, panImage.Bottom);
            this.Size = new Size(panImage.Width, LowerPanel.Bottom);
            //resize the textbox to show exactly two lines
            //panProgress.Height = txtprogress.Height;

            //this.ClientSize = new Size(this.ClientSize.Width,panImage.Height + panProgress.Height);
            this.Height = LowerPanel.Bottom + 5;

            //put in middle of the screen, as well.
            //get appropriate screen...
            Screen usescreen = Screen.FromHandle(this.Handle);
            //center on working area...
            Point uselocation = new Point(usescreen.WorkingArea.Width/2 - Width/2,
                                          usescreen.WorkingArea.Height/2 - Height/2);
            this.Location = uselocation;
            mAlphaIncrement = 0.01;
            this.Opacity = 100;

//            Bobber = new BobbingTextAnimator("BETA", 35, new Font("Arial", 72,FontStyle.Bold),0.25f,0.35f,0.007f,-35);
            //Bobber = new BobbingTextAnimator(GetExecutingVersion(), 35, new Font("Arial", 72, FontStyle.Bold), 0.25f, 0.35f, 0.007f, -35);
            String randombobtext = ChooseRandomBobText();
            Bitmap measurebob = new Bitmap(1, 1);
            Font bobberfont = BCBlockGameState.GetScaledFont(new Font("Arial", 72, FontStyle.Bold),90);
            Font biggerbobberfont = BCBlockGameState.GetScaledFont(new Font("Arial", 72, FontStyle.Bold), 128);
            Graphics mbob = Graphics.FromImage(measurebob);
            
            SizeF bobtextsize = mbob.MeasureString(randombobtext, bobberfont);
            Color RandomColor1 = getrndcolor();
            Color RandomColor2 = getrndcolor();
            float randomAngle = (float) (2*Math.PI*rgen.NextDouble());
            Brush bobtextbrush = new LinearGradientBrush(new RectangleF(0, 0, bobtextsize.Width, bobtextsize.Height),
                                                         RandomColor1, RandomColor2, randomAngle, true);

         
              FirstBobberPos = new Point((int)(320f*ScaleValue.X),(int)(157f*ScaleValue.Y));
              SecondBobberPos = new Point((int)(70f * ScaleValue.X), (int)(157f * ScaleValue.Y));
         


            Bobber =
                (Animatable)
                new BobbingTextAnimator(randombobtext, 35, bobberfont, 0.25f, 0.35f, 0.007f, -35, bobtextbrush);
            Bobber2 =
                (Animatable)
                new BobbingTextAnimator(GetExecutingVersion(), 35,biggerbobberfont, 0.25f, 0.35f,
                                        0.007f, 32, new SolidBrush(Color.Yellow));
           
            delaytimer = new Timer(timercallback, null, 0, 0);
            //alphatimer = new Timer(AlphaTick, null, 0, 10);
            tmrFade.Enabled = true;
            //BCBlockGameState.Initgamestate(this);
            assemblylist = new GenericListViewSorter(lvwAssemblies);
        }
        private void cmdPlayStop_Click(object sender, EventArgs e)
        {
            String useext = txtFileType.Text;
            //If currently playing; stop. Otherwise, play the sound data in LoadedSoundData.
            if (playingsound == null && LoadedSoundData !=null)
            {

                usedriver = BCBlockGameState.Soundman.Driver;
                mTempFilename = BCBlockGameState.GetTempFile(useext);
                //write the sounddata to that file.
                FileStream writesound = new FileStream(mTempFilename, FileMode.Create);
                writesound.Write(LoadedSoundData, 0, LoadedSoundData.Length);
                writesound.Close();
                //load a sound object from the current Driver...
                usedriver.OnSoundStop += new OnSoundStopDelegate(usedriver_OnSoundStop);

                playingsound = usedriver.LoadSound(mTempFilename);

                playedsound = playingsound.Play(false);

                cmdPlayStop.Text = "&Stop";
                //start the PositionUpdate Timer.
                PositionUpdateTimer = new Timer((w) => BeginInvoke((MethodInvoker)(() => { UpdateSoundPos(); })),null,0,250);

            }
            else
            {
                PositionUpdateTimer.Dispose();
                PositionUpdateTimer = null;
                playedsound.Stop();
                // usedriver_OnSoundStop(playedsound);
                cmdPlayStop.Text = "&Play";
                SetStopState();
            }
        }
 private async void SecondTimer(object obj)
 {
     SecondCount--;
     if ((SecondCount < 60) && (SecondCount>0))
     {
         string text = SecondCount+" "+(SecondCount == 1 ? "second" : "seconds");
         await WrapGuiAction(() => labUpdateTime.Text = text);
     }
     else if (SecondCount>=60)
     {
         int val = (SecondCount+30)/60;
         string text = val + " " + (val == 1 ? "minute" : "minutes");
         await WrapGuiAction(() => labUpdateTime.Text = text);
     }
     else
     {
         secondtimer.Dispose();
         secondtimer = null;
         await RefreshUpdates();
     }
 }
Esempio n. 12
0
 private void timercallback(object value)
 {
     //disable timer..
     Debug.Print("timercallback");
     delaytimer.Dispose();
     delaytimer = null;
     //invoke the routine to initialize the game state...
     if (!ShownAsAbout)
     {
         quickthread = new Thread(threadinitroutine);
         quickthread.Start();
     }
     bobberthread = new Thread(BobberThread);
     bobberthread.Start();
 }
 private async void butUpdateRefresh_Click(object sender, EventArgs e)
 {
     secondtimer.Dispose();
     secondtimer = null;
     Task.Factory.StartNew(async ()=>await RefreshUpdates());
 }
Esempio n. 14
0
        private void Watch(object state)
        {
            if (!File.Exists(filename))
            {
                watcher = new System.Threading.Timer(new TimerCallback(Watch), null, 5000, Timeout.Infinite);
                return;
            }
            StreamReader reader = null;

            try
            {
                FileInfo fi = new FileInfo(filename);
                if (fi.Length > streamPosition)
                {
                    reader = PrepareReader();
                    reader.BaseStream.Seek(streamPosition, SeekOrigin.Begin);
                }
                else if (fi.Length < streamPosition)
                {
                    reader         = PrepareReader();
                    streamPosition = 0;
                }
                if (reader != null)
                {
                    bool   updateNeeded = false;
                    string line         = "";
                    Entry  test         = null;
                    while (!reader.EndOfStream)
                    {
                        try
                        {
                            //FreeResources();
                            line = reader.ReadLine();
                            if (AsJson)
                            {
                                test = JsonConvert.DeserializeObject <Entry>(line);
                            }
                            else
                            {
                                Entry parsed = ParseTextLine(line, test, false);
                                if (parsed == null)
                                {
                                    continue;
                                }
                                test = parsed;
                            }

                            AddToBuffer(test);
                            if (!updateNeeded)
                            {
                                updateNeeded = true;
                                if (minDateTime == DateTime.MinValue)
                                {
                                    minDateTime = test.Created;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Program.LogParseError(line, ex);
                        }
                    }
                    streamPosition = fi.Length;
                    if (updateNeeded)
                    {
                        maxDateTime = buffer[buffer.Count - 1].Created;
                        InvalidateKnownCategories();
                        InvalidateLvEntries();
                        if (OnChangeDetected != null)
                        {
                            OnChangeDetected(this);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Log(ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.BaseStream.Close();
                    reader.Dispose();
                }
            }

            watcher = new System.Threading.Timer(new TimerCallback(Watch), null, refreshInterval, Timeout.Infinite);
        }
 private async void butUpdateRefresh_Click(object sender, EventArgs e)
 {
     secondtimer.Dispose();
     secondtimer = null;
     Task.Factory.StartNew(async() => await RefreshUpdates());
 }
Esempio n. 16
0
 /// <summary>
 /// Hàm thực hiện giám sát từng loại warning
 /// </summary>
 private void runSupervise()
 {
     int _period;
     int i = 0;
     timer = new Timer[_warningTime.Count];
     foreach (IWarningDefine w in _warningTime)
     {
         _period = w.getPeriod();
         timer[i] = new System.Threading.Timer(new TimerCallback(ShowMsg), w, 0, _period);
         if (!_dicRunWarning.ContainsKey(w.Name))
             _dicRunWarning.Add(w.Name, timer[i]);
         i++;
     }
 }
Esempio n. 17
0
        private void Watch(object state)
        {
            if (!File.Exists(filename))
            {
                watcher = new System.Threading.Timer(new TimerCallback(Watch), null, 5000, Timeout.Infinite);
                return;
            }
            StreamReader reader = null;
            try
            {
                FileInfo fi = new FileInfo(filename);
                if (fi.Length > streamPosition)
                {
                    reader = PrepareReader();
                    reader.BaseStream.Seek(streamPosition, SeekOrigin.Begin);
                }
                else if (fi.Length < streamPosition)
                {
                    reader = PrepareReader();
                    streamPosition = 0;
                }
                if (reader != null)
                {
                    bool updateNeeded = false;
                    string line = "";
                    Entry test = null;
                    while (!reader.EndOfStream)
                    {
                        try
                        {
                            //FreeResources();
                            line = reader.ReadLine();
                            if (AsJson)
                                test = JsonConvert.DeserializeObject<Entry>(line);
                            else
                            {
                                Entry parsed = ParseTextLine(line, test, false);
                                if (parsed == null)
                                    continue;
                                test = parsed;
                            }

                            AddToBuffer(test);
                            if (!updateNeeded)
                            {
                                updateNeeded = true;
                                if (minDateTime == DateTime.MinValue)
                                    minDateTime = test.Created;
                            }
                        }
                        catch (Exception ex)
                        {
                            Program.LogParseError(line, ex);
                        }
                    }
                    streamPosition = fi.Length;
                    if (updateNeeded)
                    {
                        maxDateTime = buffer[buffer.Count - 1].Created;
                        InvalidateKnownCategories();
                        InvalidateLvEntries();
                        if (OnChangeDetected != null)
                            OnChangeDetected(this);
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Log(ex);

            }
            finally
            {
                if (reader != null)
                {
                    reader.BaseStream.Close();
                    reader.Dispose();
                }
            }
            
            watcher = new System.Threading.Timer(new TimerCallback(Watch), null, refreshInterval, Timeout.Infinite);
        }
Esempio n. 18
0
        //private void FreeResources()
        //{
        //    if (memoryPerLine > 0 && buffer.Count > 250)
        //    {
        //        try
        //        {
        //            memChecker = new MemoryFailPoint(memoryPerLine);
        //        }
        //        catch (InsufficientMemoryException)
        //        {
        //            int amount = Math.Min(500, (int)Math.Ceiling((double)buffer.Count / 4));
        //            for (int i = 0; i < amount; i++)
        //            {
        //                if (visibleItems.Contains(buffer[0]))
        //                    visibleItems.Remove(buffer[0]);
        //                buffer.RemoveAt(i);
        //            }
        //        }
        //    }
        //}

        private void Parse()
        {
            int err_count = 0;
            int succ_count = 0;
            string line = "";
            Entry test = null;

            StreamReader reader = PrepareReader();

            while (!reader.EndOfStream)
            {
                try
                {
                    //if( succ_count%10 == 0 )
                    //    FreeResources();
                    //long mem1 = GC.GetTotalMemory(true);
                    line = reader.ReadLine();
                    
                    if( AsJson )
                        test = JsonConvert.DeserializeObject<Entry>(line);
                    else
                    {
                        Entry parsed = ParseTextLine(line, test, test==null);
                        if( parsed == null )
                            continue;
                        test = parsed;
                    }
                    AddToBuffer(test);
                    succ_count++;
                    //long mem2 = mem1 - GC.GetTotalMemory(false);
                    //if (mem2 > memoryPerLine)
                    //    memoryPerLine = (int)Math.Ceiling((double)mem2 / (1024 * 1024));
                }
                catch (Exception ex)
                {
                    err_count++;
                    Program.LogParseError(line, ex);
                }

                ReportProgress(0, reader.BaseStream.Length, reader.BaseStream.Position);
                if (succ_count == 0 && err_count > 10)
                {
                    RequestClose("Invalid tracefile.");
                    reader.Close();
                    return;
                }
            }
            if (buffer.Count > 0)
            {
                minDateTime = buffer[0].Created;
                maxDateTime = buffer[buffer.Count - 1].Created;
            }

            parser = null;
            InvalidateKnownCategories();
            InvalidateLvEntries();
            if (reader.BaseStream is FileStream)
                watcher = new System.Threading.Timer(new TimerCallback(Watch), null, refreshInterval, Timeout.Infinite);
            
            streamPosition = reader.BaseStream.Position;
            reader.BaseStream.Close();
            reader.Dispose();
        }
Esempio n. 19
0
        private void SplashScreen_Load(object sender, EventArgs e)
        {
            //431, 260
            chooseimage();
            this.AllowTransparency = true;
            //first, initialize image panel to 431, 260
            panImage.Location = new Point(0, 0);
            //change this if the image is changed...
            panImage.Size = new Size(431, 260);

            //clear the background of the panImage to speed drawing
            //panImage.BackgroundImage=null;

            InitBackground();
            //ImageBackBufferCanvas.DrawImage(useBackground, 0, 0, BackgroundBitmap.Width, BackgroundBitmap.Height);
            //move the lower pane...

            panProgress.Visible = !ShownAsAbout;
            PanelAbout.Visible  = ShownAsAbout;
            PanelAbout.Size     = panProgress.Size;
            if (ShownAsAbout)
            {
                LowerPanel         = PanelAbout;
                PanelAbout.Visible = true;
            }
            else
            {
                LowerPanel = panProgress;
            }
            LowerPanel.Visible = true;

            LowerPanel.Location = new Point(0, panImage.Bottom);
            this.Size           = new Size(panImage.Width, LowerPanel.Bottom);
            //resize the textbox to show exactly two lines
            //panProgress.Height = txtprogress.Height;

            //this.ClientSize = new Size(this.ClientSize.Width,panImage.Height + panProgress.Height);
            this.Height = LowerPanel.Bottom + 5;

            //put in middle of the screen, as well.
            //get appropriate screen...
            Screen usescreen = Screen.FromHandle(this.Handle);
            //center on working area...
            Point uselocation = new Point(usescreen.WorkingArea.Width / 2 - Width / 2,
                                          usescreen.WorkingArea.Height / 2 - Height / 2);

            this.Location   = uselocation;
            mAlphaIncrement = 0.01;
            this.Opacity    = 100;

//            Bobber = new BobbingTextAnimator("BETA", 35, new Font("Arial", 72,FontStyle.Bold),0.25f,0.35f,0.007f,-35);
            //Bobber = new BobbingTextAnimator(GetExecutingVersion(), 35, new Font("Arial", 72, FontStyle.Bold), 0.25f, 0.35f, 0.007f, -35);
            String   randombobtext = ChooseRandomBobText();
            Bitmap   measurebob    = new Bitmap(1, 1);
            Font     bobberfont    = new Font("Arial", 72, FontStyle.Bold);
            Graphics mbob          = Graphics.FromImage(measurebob);
            SizeF    bobtextsize   = mbob.MeasureString(randombobtext, bobberfont);
            Color    RandomColor1  = getrndcolor();
            Color    RandomColor2  = getrndcolor();
            float    randomAngle   = (float)(2 * Math.PI * rgen.NextDouble());
            Brush    bobtextbrush  = new LinearGradientBrush(new RectangleF(0, 0, bobtextsize.Width, bobtextsize.Height),
                                                             RandomColor1, RandomColor2, randomAngle, true);

            Bobber =
                (Animatable)
                new BobbingTextAnimator(randombobtext, 35, bobberfont, 0.25f, 0.35f, 0.007f, -35, bobtextbrush);
            Bobber2 =
                (Animatable)
                new BobbingTextAnimator(GetExecutingVersion(), 35, new Font("Arial", 64, FontStyle.Bold), 0.25f, 0.35f,
                                        0.007f, 32, new SolidBrush(Color.Yellow));
            //Bobber2 = (Animatable)new FallingTextAnimator(GetExecutingVersion(), new Font("Arial", 72, FontStyle.Bold), new PointF(5, 5),
            //new SolidBrush(Color.Yellow), new Pen(Color.Black), new PointF(0, 5f), new RectangleF(panImage.ClientRectangle.Left,
            //    panImage.ClientRectangle.Height, panImage.ClientRectangle.Width, panImage.ClientRectangle.Height));
            //BobberVersion = new BobbingTextAnimator(GetExecutingVersion(), 0, new Font("Segoe UI", 24, FontStyle.Bold), 1, 1, 0, 0);

            delaytimer = new Timer(timercallback, null, 0, 0);
            //alphatimer = new Timer(AlphaTick, null, 0, 10);
            tmrFade.Enabled = true;
            //BCBlockGameState.Initgamestate(this);
        }
        private void StopTickler()
        {
            if (this.tickler == null)
                return;

            this.tickler.Dispose();
            this.tickler = null;
        }
        public async Task RefreshUpdates()
        {
            if (!IsUpdateRefreshing)
            {
                IsUpdateRefreshing = true;
                await WrapGuiAction(() => labUpdateTime.Text = "Refreshing");
                List<Task<Updates>> tasks = new List<Task<Updates>>();
                foreach (string s in DownloadPluginHandler.Instance.AvailableAuthorizations)
                {
                    tasks.Add(DownloadPluginHandler.Instance.Updates(s));
                }
                await Task.WhenAll(tasks);
                List<Episode> updates=new List<Episode>();
                foreach (Task<Updates> up in tasks)
                {
                    if (up.Result.Status != ResponseStatus.Ok)
                        await WrapGuiAction(() => Log(LogType.Error, up.Result.ErrorMessage));
                    else
                        updates.AddRange(up.Result.Items);
                }
                List<EpisodeWithDownloadSettings> downloads = Follows.Instance.CheckFollows(updates);
                await WrapGuiAction(() =>
                {
                    foreach (EpisodeWithDownloadSettings d in downloads)
                    {
                        AddDownloadEpisode(d, d.Quality, d.Format,false);
                    }
                    Episode epu = null;
                    if (objUpdates.SelectedObject != null)
                        epu = (Episode)objUpdates.SelectedObject;

                    objUpdates.BeginUpdate();
                    objUpdates.SetObjects(updates);
                    objUpdates.BuildGroups(olvUpdateDate, SortOrder.Descending);
                    objUpdates.BuildList(true);
                    objUpdates.Sort(olvUpdateDate,SortOrder.Descending);

                    objUpdates.EndUpdate();
                    if (epu != null)
                    {
                        Episode n = updates.FirstOrDefault(a => a.UniqueTag == epu.UniqueTag);
                        if (n != null)
                            objUpdates.SelectedObject = n;
                    }
                });
                Episode last = updates.OrderByDescending(a => a.DateTime).FirstOrDefault();
                if (last!=null)
                    await WrapGuiAction(() => labUpdateLast.Text=last.ShowName+" "+last.EpisodeAlpha);
                IsUpdateRefreshing = false;
                IsUpdated = true;

            }
            if (secondtimer == null)
            {
                SecondCount = Settings.Instance.UpdateTime*60;
                secondtimer = new Timer(SecondTimer, null, 1000, 1000);

            }
        }
Esempio n. 22
0
 private void tbFilter_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (filterTimer != null)
         filterTimer.Dispose();
     filterTimer = new System.Threading.Timer(new TimerCallback(PerformFiltering), null, filterDelay, Timeout.Infinite);
 }
Esempio n. 23
0
        //private void FreeResources()
        //{
        //    if (memoryPerLine > 0 && buffer.Count > 250)
        //    {
        //        try
        //        {
        //            memChecker = new MemoryFailPoint(memoryPerLine);
        //        }
        //        catch (InsufficientMemoryException)
        //        {
        //            int amount = Math.Min(500, (int)Math.Ceiling((double)buffer.Count / 4));
        //            for (int i = 0; i < amount; i++)
        //            {
        //                if (visibleItems.Contains(buffer[0]))
        //                    visibleItems.Remove(buffer[0]);
        //                buffer.RemoveAt(i);
        //            }
        //        }
        //    }
        //}

        private void Parse()
        {
            int    err_count  = 0;
            int    succ_count = 0;
            string line       = "";
            Entry  test       = null;

            StreamReader reader = PrepareReader();

            while (!reader.EndOfStream)
            {
                try
                {
                    //if( succ_count%10 == 0 )
                    //    FreeResources();
                    //long mem1 = GC.GetTotalMemory(true);
                    line = reader.ReadLine();

                    if (AsJson)
                    {
                        test = JsonConvert.DeserializeObject <Entry>(line);
                    }
                    else
                    {
                        Entry parsed = ParseTextLine(line, test, test == null);
                        if (parsed == null)
                        {
                            continue;
                        }
                        test = parsed;
                    }
                    AddToBuffer(test);
                    succ_count++;
                    //long mem2 = mem1 - GC.GetTotalMemory(false);
                    //if (mem2 > memoryPerLine)
                    //    memoryPerLine = (int)Math.Ceiling((double)mem2 / (1024 * 1024));
                }
                catch (Exception ex)
                {
                    err_count++;
                    Program.LogParseError(line, ex);
                }

                ReportProgress(0, reader.BaseStream.Length, reader.BaseStream.Position);
                if (succ_count == 0 && err_count > 10)
                {
                    RequestClose("Invalid tracefile.");
                    reader.Close();
                    return;
                }
            }
            if (buffer.Count > 0)
            {
                minDateTime = buffer[0].Created;
                maxDateTime = buffer[buffer.Count - 1].Created;
            }

            parser = null;
            InvalidateKnownCategories();
            InvalidateLvEntries();
            if (reader.BaseStream is FileStream)
            {
                watcher = new System.Threading.Timer(new TimerCallback(Watch), null, refreshInterval, Timeout.Infinite);
            }

            streamPosition = reader.BaseStream.Position;
            reader.BaseStream.Close();
            reader.Dispose();
        }
        public async Task RefreshUpdates()
        {
            if (!IsUpdateRefreshing)
            {
                IsUpdateRefreshing = true;
                await WrapGuiAction(() => labUpdateTime.Text = "Refreshing");

                List <Task <Updates> > tasks = new List <Task <Updates> >();
                foreach (string s in DownloadPluginHandler.Instance.AvailableAuthorizations)
                {
                    tasks.Add(DownloadPluginHandler.Instance.Updates(s));
                }
                await Task.WhenAll(tasks);

                List <Episode> updates = new List <Episode>();
                foreach (Task <Updates> up in tasks)
                {
                    if (up.Result.Status != ResponseStatus.Ok)
                    {
                        await WrapGuiAction(() => Log(LogType.Error, up.Result.ErrorMessage));
                    }
                    else
                    {
                        updates.AddRange(up.Result.Items);
                    }
                }
                List <EpisodeWithDownloadSettings> downloads = Follows.Instance.CheckFollows(updates);
                await WrapGuiAction(() =>
                {
                    foreach (EpisodeWithDownloadSettings d in downloads)
                    {
                        AddDownloadEpisode(d, d.Quality, d.Format, false);
                    }
                    Episode epu = null;
                    if (objUpdates.SelectedObject != null)
                    {
                        epu = (Episode)objUpdates.SelectedObject;
                    }

                    objUpdates.BeginUpdate();
                    objUpdates.SetObjects(updates);
                    objUpdates.BuildGroups(olvUpdateDate, SortOrder.Descending);
                    objUpdates.BuildList(true);
                    objUpdates.Sort(olvUpdateDate, SortOrder.Descending);

                    objUpdates.EndUpdate();
                    if (epu != null)
                    {
                        Episode n = updates.FirstOrDefault(a => a.UniqueTag == epu.UniqueTag);
                        if (n != null)
                        {
                            objUpdates.SelectedObject = n;
                        }
                    }
                });

                Episode last = updates.OrderByDescending(a => a.DateTime).FirstOrDefault();
                if (last != null)
                {
                    await WrapGuiAction(() => labUpdateLast.Text = last.ShowName + " " + last.EpisodeAlpha);
                }
                IsUpdateRefreshing = false;
                IsUpdated          = true;
            }
            if (secondtimer == null)
            {
                SecondCount = Settings.Instance.UpdateTime * 60;
                secondtimer = new Timer(SecondTimer, null, 1000, 1000);
            }
        }
Esempio n. 25
0
        private void TmrSeverConnectionStart()
        {
            if (_tmrSeverConnection != null) _tmrSeverConnection.Dispose(); // Stop Timer
            _nCountServerConnection = 0;
            System.Threading.TimerCallback callback = TmrSeverConnectionEvent;
            Object data = (Object)200;

            _tmrSeverConnection = new System.Threading.Timer(callback, data, 1000, 5000);
        }