Example #1
0
        public void Send()
        {
            _mt.SynchronizationContext.Should().BeOfType(typeof(MainThread.MainThreadSynchronizationContext));
            _mt.ThreadId.Should().Be(_mt.Thread.ManagedThreadId);

            var tcs = new TaskCompletionSource <bool>();

            _mt.Send(o => tcs.TrySetResult(true), null);
            tcs.Task.IsCompleted.Should().BeTrue();

            tcs = new TaskCompletionSource <bool>();
            _mt.SynchronizationContext.Send(o => tcs.TrySetResult(true), null);
            tcs.Task.IsCompleted.Should().BeTrue();
        }
        protected ConfirmationData ConfirmObjectAction(string tag, string objectName)
        {
            try
            {
                _fileTaskWaitEvent.Set();
                TaskbarThumbnailManager.Instance.SetProgressStatus(TaskbarProgressBarStatus.Paused);

                ConfirmationData retVal = new ConfirmationData();

                MainThread.Send(delegate(object x)
                {
                    DialogResult dr = DialogResult.Abort;

                    if (_task.ObjectsCount == 1)
                    {
                        dr = MessageDisplay.Query(
                            Translator.Translate(tag, objectName), "TXT_CONFIRM");
                    }
                    else
                    {
                        dr = MessageDisplay.QueryWithCancelAndAbort(
                            Translator.Translate(tag, objectName),
                            "TXT_CONFIRM", (_task.ObjectsCount > 1));
                    }

                    switch (dr)
                    {
                    case DialogResult.Abort:
                        CanContinue = false;
                        break;

                    case DialogResult.No:
                        retVal.ConfirmationResult = false;
                        break;

                    case DialogResult.Yes:
                        retVal.ConfirmationResult = true;
                        break;

                    case DialogResult.OK:     // YES ALL
                        retVal.ConfirmationResult = true;
                        retVal.FlagValue          = true;
                        break;
                    }
                });

                return(retVal);
            }
            finally
            {
                _fileTaskWaitEvent.Reset();
                TaskbarThumbnailManager.Instance.SetProgressStatus(TaskbarProgressBarStatus.Normal);
            }
        }
Example #3
0
        protected virtual void SearchInternal(OnlineContentSearchParameters searchParams, ManualResetEvent abortEvent)
        {
            this.Items.Clear();
            this.SelectedItems.Clear();

            if (searchParams.SearchText == "LookupMyPlaylists")
            {
                var playlists = OnlineContentSearcher.GetMyPlaylists(_searchType, abortEvent);
                if (playlists != null && playlists.Count > 0)
                {
                    OnlinePlaylist p = null;

                    MainThread.Send((c) =>
                    {
                        SelectOnlinePlaylistDlg dlg = new SelectOnlinePlaylistDlg(playlists);
                        if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
                        {
                            p = dlg.SelectedItem;
                        }
                    });

                    if (p != null)
                    {
                        var results = OnlineContentSearcher.ExpandOnlinePlaylist(_searchType, p, abortEvent);
                        if (results != null && results.Count > 0)
                        {
                            this.Items.AddRange(results);
                        }
                    }
                }
            }
            else
            {
                var results = OnlineContentSearcher.Search(_searchType, searchParams, abortEvent);
                if (results != null && results.Count > 0)
                {
                    this.Items.AddRange(results);
                }
            }
        }
        private void PreProcessEvent(SchedulerAction action, string msg)
        {
            _action = action;

            _canProceed.Reset();

            ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessEvent));

            if (ProTONEConfig.SchedulerWaitTimerProceed > 0)
            {
                _action = SchedulerAction.None;

                if (action != SchedulerAction.None)
                {
                    Logger.LogInfo("Asking the user how to continue with action: " + action);

                    bool res = false;

                    MainThread.Send(delegate(object x)
                    {
                        res = QueryScheduledAction(action, msg);

                    });

                    if (res)
                    {
                        Logger.LogInfo("The user has chosen to continue with the action");
                        _action = action;
                    }
                    else
                    {
                        Logger.LogInfo("The user has chosen to abort the action");
                    }
                }
            }

            _canProceed.Set();
        }