コード例 #1
0
ファイル: Worker.cs プロジェクト: aledkov/XrmToolBox
        public void WorkAsync(WorkAsyncInfo info)
        {
            if (info.Host == null)
            {
                throw new NullReferenceException("WorkAsyncInfo Host property is null!");
            }

            _infoPanel = InformationPanel.GetInformationPanel(info.Host, info.Message, info.MessageWidth, info.MessageHeight);
            _worker    = new BackgroundWorker
            {
                WorkerReportsProgress      = info.ProgressChanged != null,
                WorkerSupportsCancellation = info.IsCancelable
            };
            _worker.DoWork += info.PerformWork;

            if (_worker.WorkerReportsProgress && info.ProgressChanged != null)
            {
                _worker.ProgressChanged += info.PerformProgressChange;
            }

            if (info.PostWorkCallBack != null)
            {
                _worker.RunWorkerCompleted += (s, e) =>
                {
                    if (info.Host.Controls.Contains(_infoPanel))
                    {
                        _infoPanel.Dispose();
                        info.Host.Controls.Remove(_infoPanel);
                    }
                    info.PostWorkCallBack(e);
                };
            }

            _worker.RunWorkerAsync(info.AsyncArgument);
        }
コード例 #2
0
ファイル: Worker.cs プロジェクト: RazDynamics/XrmToolBox
        public void WorkAsync(WorkAsyncInfo info)
        {
            if (info.Host == null)
            {
                throw new NullReferenceException("WorkAsyncInfo Host property is null!");
            }

            _infoPanel = InformationPanel.GetInformationPanel(info.Host, info.Message, info.MessageWidth, info.MessageHeight);
            _worker = new BackgroundWorker
            {
                WorkerReportsProgress = info.ProgressChanged != null,
                WorkerSupportsCancellation = info.IsCancelable
            };
            _worker.DoWork += info.PerformWork;

            if (_worker.WorkerReportsProgress && info.ProgressChanged != null)
            {
                _worker.ProgressChanged += info.PerformProgressChange;
            }

            _worker.RunWorkerCompleted += (s, e) =>
            {
                if (info.Host.Controls.Contains(_infoPanel))
                {
                    _infoPanel.Dispose();
                    info.Host.Controls.Remove(_infoPanel);
                }
                if (info.PostWorkCallBack != null)
                {
                    info.PostWorkCallBack(e);
                }
            };

            _worker.RunWorkerAsync(info.AsyncArgument);
        }
コード例 #3
0
        public void WorkAsync(WorkAsyncInfo info)
        {
            info.Host = this;
            _worker   = new Worker();
            _worker.WorkAsync(info);

            OnWorkAsync?.Invoke(this, new EventArgs());
        }
コード例 #4
0
 public void WorkAsync(string message, Action<DoWorkEventArgs> work, object argument = null, int messageWidth = 340, int messageHeight = 150)
 {
     var info = new WorkAsyncInfo(message, work)
     {
         AsyncArgument = argument,
         Host = this,
         MessageWidth = messageWidth,
         MessageHeight = messageHeight
     };
     WorkAsync(info);
 }
コード例 #5
0
 public void WorkAsync(string message, Action<DoWorkEventArgs> work, Action<RunWorkerCompletedEventArgs> callback, object argument = null, int messageWidth = 340, int messageHeight = 150)
 {
     var info = new WorkAsyncInfo(message, work)
     {
         AsyncArgument = argument,
         Host = this,
         MessageWidth = messageWidth,
         MessageHeight = messageHeight,
         PostWorkCallBack = callback
     };
     WorkAsync(info);
 }
コード例 #6
0
        public void WorkAsync(string message, Action <BackgroundWorker, DoWorkEventArgs> work, object argument, bool enableCancellation, int messageWidth, int messageHeight)
        {
            var info = new WorkAsyncInfo(message, work)
            {
                AsyncArgument = argument,
                Host          = this,
                IsCancelable  = enableCancellation,
                MessageWidth  = messageWidth,
                MessageHeight = messageHeight
            };

            _worker.WorkAsync(info);
        }
コード例 #7
0
 public void WorkAsync(string message, Action<BackgroundWorker, DoWorkEventArgs> work, Action<RunWorkerCompletedEventArgs> callback, object argument, bool enableCancellation, int messageWidth, int messageHeight)
 {
     var info = new WorkAsyncInfo(message, work)
     {
         AsyncArgument = argument,
         Host = this,
         IsCancelable = enableCancellation,
         MessageWidth = messageWidth,
         MessageHeight = messageHeight,
         PostWorkCallBack = callback
     };
     WorkAsync(info);
 }
コード例 #8
0
        public void WorkAsync(string message, Action <BackgroundWorker, DoWorkEventArgs> work, Action <RunWorkerCompletedEventArgs> callback,
                              Action <ProgressChangedEventArgs> progressChanged, object argument = null, int messageWidth = 340, int messageHeight = 150)
        {
            var info = new WorkAsyncInfo(message, work)
            {
                AsyncArgument    = argument,
                Host             = this,
                MessageWidth     = messageWidth,
                MessageHeight    = messageHeight,
                PostWorkCallBack = callback,
                ProgressChanged  = progressChanged
            };

            _worker.WorkAsync(info);
        }
コード例 #9
0
 public void WorkAsync(WorkAsyncInfo info)
 {
     info.Host = this;
     _worker.WorkAsync(info);
 }
コード例 #10
0
 public void WorkAsync(WorkAsyncInfo info)
 {
     info.Host = this;
     _worker.WorkAsync(info);
 }