Exemplo n.º 1
0
        void ReleaseDesignerOutlets ()
        {
            if (Cancel != null) {
                Cancel.Dispose ();
                Cancel = null;
            }

            if (DeselectAllAction != null) {
                DeselectAllAction.Dispose ();
                DeselectAllAction = null;
            }

            if (Download != null) {
                Download.Dispose ();
                Download = null;
            }

            if (SelectAllAction != null) {
                SelectAllAction.Dispose ();
                SelectAllAction = null;
            }

            if (tableView != null) {
                tableView.Dispose ();
                tableView = null;
            }
        }
Exemplo n.º 2
0
        void ReleaseDesignerOutlets()
        {
            if (Cancel != null)
            {
                Cancel.Dispose();
                Cancel = null;
            }

            if (mLateCharge != null)
            {
                mLateCharge.Dispose();
                mLateCharge = null;
            }

            if (mNewCharge != null)
            {
                mNewCharge.Dispose();
                mNewCharge = null;
            }

            if (mReport != null)
            {
                mReport.Dispose();
                mReport = null;
            }

            if (Save != null)
            {
                Save.Dispose();
                Save = null;
            }
        }
Exemplo n.º 3
0
        void ReleaseDesignerOutlets()
        {
            if (Cancel != null)
            {
                Cancel.Dispose();
                Cancel = null;
            }

            if (FeedbackArea != null)
            {
                FeedbackArea.Dispose();
                FeedbackArea = null;
            }

            if (ProgressBar != null)
            {
                ProgressBar.Dispose();
                ProgressBar = null;
            }

            if (UpdateText != null)
            {
                UpdateText.Dispose();
                UpdateText = null;
            }
        }
Exemplo n.º 4
0
 public async Task SleepAsync()
 {
     Interlocked.CompareExchange(ref _running, 2, 1);             // If running, make it stopping.
     Cancel?.Cancel();
     while (Interlocked.CompareExchange(ref _running, 3, 0) == 2)
     {
         await Task.Delay(50);                 // wait for Start() loop to Cancel
     }
     Cancel?.Dispose();
     Cancel = null;
 }
Exemplo n.º 5
0
        public async Task StopAsync()
        {
            Synchronizer.ResponseArrived -= Synchronizer_ResponseArrivedAsync;

            if (IsRunning)
            {
                Interlocked.Exchange(ref _running, 2);
            }
            Cancel?.Cancel();
            while (IsStopping)
            {
                Task.Delay(50).GetAwaiter().GetResult();                 // DO NOT MAKE IT ASYNC (.NET Core threading brainfart)
            }

            Cancel?.Dispose();

            using (await MixLock.LockAsync())
            {
                await DequeueCoinsFromMixNoLockAsync(State.GetSpentCoins().ToArray());

                State.DisposeAllAliceClients();

                IEnumerable <TxoRef> allCoins = State.GetAllQueuedCoins();
                foreach (var coinReference in allCoins)
                {
                    try
                    {
                        var coin = State.GetSingleOrDefaultFromWaitingList(coinReference);
                        if (coin is null)
                        {
                            continue;                             // The coin isn't present anymore. Good. This should never happen though.
                        }
                        await DequeueCoinsFromMixNoLockAsync(coin.GetTxoRef());
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError <CcjClient>("Couldn't dequeue all coins. Some coins will likely be banned from mixing.");
                        if (ex is AggregateException)
                        {
                            var aggrEx = ex as AggregateException;
                            foreach (var innerEx in aggrEx.InnerExceptions)
                            {
                                Logger.LogError <CcjClient>(innerEx);
                            }
                        }
                        else
                        {
                            Logger.LogError <CcjClient>(ex);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public async Task StopAsync()
        {
            Synchronizer.ResponseArrived -= Synchronizer_ResponseArrivedAsync;

            Interlocked.CompareExchange(ref _running, 2, 1);             // If running, make it stopping.
            Cancel?.Cancel();
            while (Interlocked.CompareExchange(ref _running, 3, 0) == 2)
            {
                await Task.Delay(50);
            }

            Cancel?.Dispose();
            Cancel = null;

            using (await MixLock.LockAsync())
            {
                await DequeueSpentCoinsFromMixNoLockAsync();

                State.DisposeAllAliceClients();

                IEnumerable <TxoRef> allCoins = State.GetAllQueuedCoins();
                foreach (var coinReference in allCoins)
                {
                    try
                    {
                        var coin = State.GetSingleOrDefaultFromWaitingList(coinReference);
                        if (coin is null)
                        {
                            continue;                             // The coin isn't present anymore. Good. This should never happen though.
                        }
                        await DequeueCoinsFromMixNoLockAsync(coin.GetTxoRef(), "Stopping Wasabi.");
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError <CcjClient>("Couldn't dequeue all coins. Some coins will likely be banned from mixing.");
                        if (ex is AggregateException)
                        {
                            var aggrEx = ex as AggregateException;
                            foreach (var innerEx in aggrEx.InnerExceptions)
                            {
                                Logger.LogError <CcjClient>(innerEx);
                            }
                        }
                        else
                        {
                            Logger.LogError <CcjClient>(ex);
                        }
                    }
                }
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (Cancel != null)
            {
                Cancel.Dispose();
                Cancel = null;
            }

            if (mCurrentPoss != null)
            {
                mCurrentPoss.Dispose();
                mCurrentPoss = null;
            }

            if (mLateCharge != null)
            {
                mLateCharge.Dispose();
                mLateCharge = null;
            }

            if (mNewCharge != null)
            {
                mNewCharge.Dispose();
                mNewCharge = null;
            }

            if (mPossDown != null)
            {
                mPossDown.Dispose();
                mPossDown = null;
            }

            if (mPossUp != null)
            {
                mPossUp.Dispose();
                mPossUp = null;
            }

            if (mReport != null)
            {
                mReport.Dispose();
                mReport = null;
            }

            if (Save != null)
            {
                Save.Dispose();
                Save = null;
            }
        }
Exemplo n.º 8
0
 void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         Statistical.SetProgressRate(Color.Maroon);
         Console.WriteLine(e.Error.StackTrace);
     }
     else if (e.Cancelled)
     {
         Statistical.SetProgressRate(e.Cancelled);
         Statistical.SetProgressRate(Color.Ivory);
     }
     else
     {
         Statistical.SetProgressRate((bool)e.Result);
         Statistical.SetProgressRate(Color.Ivory);
     }
     Cancel.Dispose();
 }
        void ReleaseDesignerOutlets()
        {
            if (btnSaveSettings != null)
            {
                btnSaveSettings.Dispose();
                btnSaveSettings = null;
            }

            if (Cancel != null)
            {
                Cancel.Dispose();
                Cancel = null;
            }

            if (FaceEndpoint != null)
            {
                FaceEndpoint.Dispose();
                FaceEndpoint = null;
            }

            if (FaceKey != null)
            {
                FaceKey.Dispose();
                FaceKey = null;
            }

            if (VisionEndpoint != null)
            {
                VisionEndpoint.Dispose();
                VisionEndpoint = null;
            }

            if (VisionKey != null)
            {
                VisionKey.Dispose();
                VisionKey = null;
            }
        }
Exemplo n.º 10
0
        void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            var list  = client.GetContext(new Catalog.Codes(), 6).Result as List <Catalog.Codes>;
            var stack = new Stack <IStrategics>();

            foreach (var strategics in new IStrategics[]
            {
                new Catalog.TrendsInStockPrices(),
                new Catalog.ScenarioAccordingToTrend(),
                new Catalog.TrendToCashflow()
            })
            {
                foreach (var enumerable in client.GetContext(strategics).Result)
                {
                    stack.Push(enumerable);
                }
            }

            ulong maximum = (ulong)(list.Count * stack.Count), rate = 0;
            var   po = new ParallelOptions
            {
                CancellationToken      = Cancel.Token,
                MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * 0.25)
            };

            while (stack.Count > 0)
            {
                try
                {
                    var strategics = stack.Pop();
                    Parallel.ForEach(list.OrderBy(o => Guid.NewGuid()), po, new Action <Catalog.Codes>((w) =>
                    {
                        if (backgroundWorker.CancellationPending)
                        {
                            e.Cancel = true;

                            if (Cancel.IsCancellationRequested)
                            {
                                po.CancellationToken.ThrowIfCancellationRequested();
                            }
                        }
                        else if (IsTheCorrectInformation(w))
                        {
                            var now          = DateTime.Now;
                            HoldingStocks hs = null;

                            switch (strategics)
                            {
                            case Catalog.ScenarioAccordingToTrend st:
                                var consensus = client.GetContext(new Catalog.ConvertConsensus {
                                    Code = w.Code
                                }).Result;

                                if (consensus != null && consensus.Any(o => o.Date.EndsWith("(E)") && o.Date.StartsWith(now.AddYears(2).ToString("yy"))) && client.PostContext(new ConfirmStrategics
                                {
                                    Code = w.Code,
                                    Date = now.Hour > 0xF ? now.ToString(format) : now.AddDays(-1).ToString(format),
                                    Strategics = string.Concat("ST.", st.Calendar, '.', st.Trend, '.', st.CheckSales.ToString().Substring(0, 1), '.', (uint)(st.Sales * 0x64), '.', st.CheckOperatingProfit.ToString().Substring(0, 1), '.', (uint)(st.OperatingProfit * 0x64), '.', st.CheckNetIncome.ToString().Substring(0, 1), '.', (uint)(st.NetIncome * 0x64))
                                }).Result == false)
                                {
                                    st.Code = w.Code;
                                    hs      = new HoldingStocks(st, new Catalog.ConvertConsensus().PresumeToConsensus(consensus), client)
                                    {
                                        Code = st.Code
                                    };
                                    hs.SendBalance += OnReceiveAnalysisData;
                                    hs.StartProgress(0D);
                                }
                                break;

                            case Catalog.TrendToCashflow tc:
                                if (client.PostContext(new ConfirmStrategics
                                {
                                    Code = w.Code,
                                    Date = now.Hour > 0xF ? now.ToString(format) : now.AddDays(-1).ToString(format),
                                    Strategics = string.Concat("TC.", tc.AnalysisType)
                                }).Result == false)
                                {
                                    tc.Code = w.Code;
                                    hs      = new HoldingStocks(tc, client)
                                    {
                                        Code = tc.Code
                                    };
                                    hs.SendBalance += OnReceiveAnalysisData;
                                    hs.StartProgress(0D);
                                }
                                break;

                            case Catalog.TrendsInStockPrices ts:
                                if (client.PostContext(new ConfirmStrategics
                                {
                                    Code = w.Code,
                                    Date = now.Hour > 0xF ? now.ToString(format) : now.AddDays(-1).ToString(format),
                                    Strategics = string.Concat("TS.", ts.Short, '.', ts.Long, '.', ts.Trend, '.', (int)(ts.RealizeProfit * 0x2710), '.', (int)(ts.AdditionalPurchase * 0x2710), '.', ts.QuoteUnit, '.', (char)ts.LongShort, '.', (char)ts.TrendType, '.', (char)ts.Setting)
                                }).Result == false)
                                {
                                    ts.Code = w.Code;
                                    hs      = new HoldingStocks(ts)
                                    {
                                        Code = ts.Code
                                    };
                                    hs.SendBalance += OnReceiveAnalysisData;
                                    hs.StartProgress(0D);
                                }
                                break;
                            }
                            if (hs != null)
                            {
                                hs.SendBalance -= OnReceiveAnalysisData;
                            }
                        }
                        Statistical.SetProgressRate(Color.Gold);
                        backgroundWorker.ReportProgress((int)(rate++ *1e+2 / maximum));
                    }));
                }
                catch (OperationCanceledException ex)
                {
                    Statistical.SetProgressRate(Color.Ivory);
                    Cancel.Dispose();
                    Console.WriteLine("Count_" + rate + "\t" + ex.TargetSite.Name);
                }
            }
        void ReleaseDesignerOutlets()
        {
            if (AccountData != null)
            {
                AccountData.Dispose();
                AccountData = null;
            }

            if (AccountDataSection != null)
            {
                AccountDataSection.Dispose();
                AccountDataSection = null;
            }

            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (Cancel != null)
            {
                Cancel.Dispose();
                Cancel = null;
            }

            if (ChangePassword != null)
            {
                ChangePassword.Dispose();
                ChangePassword = null;
            }

            if (ChangePasswordSection != null)
            {
                ChangePasswordSection.Dispose();
                ChangePasswordSection = null;
            }

            if (CheckUsername != null)
            {
                CheckUsername.Dispose();
                CheckUsername = null;
            }

            if (ConfirmPassword != null)
            {
                ConfirmPassword.Dispose();
                ConfirmPassword = null;
            }

            if (ConfirmPasswordLabel != null)
            {
                ConfirmPasswordLabel.Dispose();
                ConfirmPasswordLabel = null;
            }

            if (DeactivateAccount != null)
            {
                DeactivateAccount.Dispose();
                DeactivateAccount = null;
            }

            if (DeleteAccount != null)
            {
                DeleteAccount.Dispose();
                DeleteAccount = null;
            }

            if (DescriptionLabel != null)
            {
                DescriptionLabel.Dispose();
                DescriptionLabel = null;
            }

            if (DescriptionText != null)
            {
                DescriptionText.Dispose();
                DescriptionText = null;
            }

            if (DistanceShareAll != null)
            {
                DistanceShareAll.Dispose();
                DistanceShareAll = null;
            }

            if (DistanceShareAllLabel != null)
            {
                DistanceShareAllLabel.Dispose();
                DistanceShareAllLabel = null;
            }

            if (DistanceShareFriend != null)
            {
                DistanceShareFriend.Dispose();
                DistanceShareFriend = null;
            }

            if (DistanceShareFriendLabel != null)
            {
                DistanceShareFriendLabel.Dispose();
                DistanceShareFriendLabel = null;
            }

            if (DistanceShareLabel != null)
            {
                DistanceShareLabel.Dispose();
                DistanceShareLabel = null;
            }

            if (DistanceShareLike != null)
            {
                DistanceShareLike.Dispose();
                DistanceShareLike = null;
            }

            if (DistanceShareLikeLabel != null)
            {
                DistanceShareLikeLabel.Dispose();
                DistanceShareLikeLabel = null;
            }

            if (DistanceShareMatch != null)
            {
                DistanceShareMatch.Dispose();
                DistanceShareMatch = null;
            }

            if (DistanceShareMatchLabel != null)
            {
                DistanceShareMatchLabel.Dispose();
                DistanceShareMatchLabel = null;
            }

            if (DistanceShareNone != null)
            {
                DistanceShareNone.Dispose();
                DistanceShareNone = null;
            }

            if (DistanceShareNoneLabel != null)
            {
                DistanceShareNoneLabel.Dispose();
                DistanceShareNoneLabel = null;
            }

            if (EditImagesUploaded != null)
            {
                EditImagesUploaded.Dispose();
                EditImagesUploaded = null;
            }

            if (Email != null)
            {
                Email.Dispose();
                Email = null;
            }

            if (EmailLabel != null)
            {
                EmailLabel.Dispose();
                EmailLabel = null;
            }

            if (ImageEditor != null)
            {
                ImageEditor.Dispose();
                ImageEditor = null;
            }

            if (ImageEditorCancel != null)
            {
                ImageEditorCancel.Dispose();
                ImageEditorCancel = null;
            }

            if (ImageEditorControls != null)
            {
                ImageEditorControls.Dispose();
                ImageEditorControls = null;
            }

            if (ImageEditorFrame != null)
            {
                ImageEditorFrame.Dispose();
                ImageEditorFrame = null;
            }

            if (ImageEditorFrameBorder != null)
            {
                ImageEditorFrameBorder.Dispose();
                ImageEditorFrameBorder = null;
            }

            if (ImageEditorLabel != null)
            {
                ImageEditorLabel.Dispose();
                ImageEditorLabel = null;
            }

            if (ImageEditorOK != null)
            {
                ImageEditorOK.Dispose();
                ImageEditorOK = null;
            }

            if (ImageEditorStatus != null)
            {
                ImageEditorStatus.Dispose();
                ImageEditorStatus = null;
            }

            if (Images != null)
            {
                Images.Dispose();
                Images = null;
            }

            if (ImagesProgress != null)
            {
                ImagesProgress.Dispose();
                ImagesProgress = null;
            }

            if (ImagesProgressText != null)
            {
                ImagesProgressText.Dispose();
                ImagesProgressText = null;
            }

            if (LoaderCircle != null)
            {
                LoaderCircle.Dispose();
                LoaderCircle = null;
            }

            if (LocationSettings != null)
            {
                LocationSettings.Dispose();
                LocationSettings = null;
            }

            if (LocationSettingsSection != null)
            {
                LocationSettingsSection.Dispose();
                LocationSettingsSection = null;
            }

            if (LocationShareAll != null)
            {
                LocationShareAll.Dispose();
                LocationShareAll = null;
            }

            if (LocationShareAllLabel != null)
            {
                LocationShareAllLabel.Dispose();
                LocationShareAllLabel = null;
            }

            if (LocationShareFriend != null)
            {
                LocationShareFriend.Dispose();
                LocationShareFriend = null;
            }

            if (LocationShareFriendLabel != null)
            {
                LocationShareFriendLabel.Dispose();
                LocationShareFriendLabel = null;
            }

            if (LocationShareLabel != null)
            {
                LocationShareLabel.Dispose();
                LocationShareLabel = null;
            }

            if (LocationShareLike != null)
            {
                LocationShareLike.Dispose();
                LocationShareLike = null;
            }

            if (LocationShareLikeLabel != null)
            {
                LocationShareLikeLabel.Dispose();
                LocationShareLikeLabel = null;
            }

            if (LocationShareMatch != null)
            {
                LocationShareMatch.Dispose();
                LocationShareMatch = null;
            }

            if (LocationShareMatchLabel != null)
            {
                LocationShareMatchLabel.Dispose();
                LocationShareMatchLabel = null;
            }

            if (LocationShareNone != null)
            {
                LocationShareNone.Dispose();
                LocationShareNone = null;
            }

            if (LocationShareNoneLabel != null)
            {
                LocationShareNoneLabel.Dispose();
                LocationShareNoneLabel = null;
            }

            if (Men != null)
            {
                Men.Dispose();
                Men = null;
            }

            if (MenLabel != null)
            {
                MenLabel.Dispose();
                MenLabel = null;
            }

            if (MoreOptions != null)
            {
                MoreOptions.Dispose();
                MoreOptions = null;
            }

            if (MoreOptionsSection != null)
            {
                MoreOptionsSection.Dispose();
                MoreOptionsSection = null;
            }

            if (Name != null)
            {
                Name.Dispose();
                Name = null;
            }

            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (NewPassword != null)
            {
                NewPassword.Dispose();
                NewPassword = null;
            }

            if (NewPasswordLabel != null)
            {
                NewPasswordLabel.Dispose();
                NewPasswordLabel = null;
            }

            if (OldPassword != null)
            {
                OldPassword.Dispose();
                OldPassword = null;
            }

            if (OldPasswordLabel != null)
            {
                OldPasswordLabel.Dispose();
                OldPasswordLabel = null;
            }

            if (ProfileEdit_Scroll != null)
            {
                ProfileEdit_Scroll.Dispose();
                ProfileEdit_Scroll = null;
            }

            if (RippleImageEditor != null)
            {
                RippleImageEditor.Dispose();
                RippleImageEditor = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (Save != null)
            {
                Save.Dispose();
                Save = null;
            }

            if (ScrollBottomConstraint != null)
            {
                ScrollBottomConstraint.Dispose();
                ScrollBottomConstraint = null;
            }

            if (ScrollBottomOuterConstraint != null)
            {
                ScrollBottomOuterConstraint.Dispose();
                ScrollBottomOuterConstraint = null;
            }

            if (SexLabel != null)
            {
                SexLabel.Dispose();
                SexLabel = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (TopSeparator != null)
            {
                TopSeparator.Dispose();
                TopSeparator = null;
            }

            if (UseLocationLabel != null)
            {
                UseLocationLabel.Dispose();
                UseLocationLabel = null;
            }

            if (UseLocationSwitch != null)
            {
                UseLocationSwitch.Dispose();
                UseLocationSwitch = null;
            }

            if (Username != null)
            {
                Username.Dispose();
                Username = null;
            }

            if (UsernameLabel != null)
            {
                UsernameLabel.Dispose();
                UsernameLabel = null;
            }

            if (ViewportConstraint != null)
            {
                ViewportConstraint.Dispose();
                ViewportConstraint = null;
            }

            if (Women != null)
            {
                Women.Dispose();
                Women = null;
            }

            if (WomenLabel != null)
            {
                WomenLabel.Dispose();
                WomenLabel = null;
            }
        }
Exemplo n.º 12
0
 public void Dispose()
 {
     CancelAllOpenTasks();
     Cancel.Dispose();
 }