本文整理汇总了C#中System.ComponentModel.BackgroundWorker类的典型用法代码示例。如果您正苦于以下问题:C# System.ComponentModel.BackgroundWorker类的具体用法?C# System.ComponentModel.BackgroundWorker怎么用?C# System.ComponentModel.BackgroundWorker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.ComponentModel.BackgroundWorker类属于命名空间,在下文中一共展示了System.ComponentModel.BackgroundWorker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendToWebSevice
public SendToWebSevice()
{
SendVdxFile = new System.ComponentModel.BackgroundWorker();
SendVdxFile.DoWork += new System.ComponentModel.DoWorkEventHandler(SendVdxFile_DoWork);
SendVdxFile.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(SendVdxFile_RunWorkerCompleted);
}
示例2: RoseHAService
public RoseHAService()
{
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.WorkerSupportsCancellation = true;
backgroundWorker1.DoWork += backgroundWorker1_DoWork;
}
示例3: SendRequest
public void SendRequest(string postRequest, Microsoft.Phone.Controls.PerformanceProgressBar performanceProgressBar)
{
var bw = new System.ComponentModel.BackgroundWorker();
bw.DoWork += (s, args) => // This runs on a background thread.
{
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
performanceProgressBar.IsIndeterminate = true;
performanceProgressBar.Visibility = System.Windows.Visibility.Visible;
});
this.parameters = postRequest;
this.request = WebRequest.Create(new Uri("http://192.168.1.71:8080/MobileApplication/mythapi")) as WebRequest;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.BeginGetRequestStream(ReadCallback, request);
};
bw.RunWorkerCompleted += (s, args) =>
{
// Do your UI work here this will run on the UI thread.
// Clear progress bar.
performanceProgressBar.IsIndeterminate = false;
performanceProgressBar.Visibility = System.Windows.Visibility.Collapsed;
};
bw.RunWorkerAsync();
}
示例4: ThumbnailCreator
/// <summary>
/// Initializes a new instance of the <see cref="ThumbnailCreator"/> class.
/// </summary>
/// <param name="tnSettings">The <see cref="ThumbnailSettings"/> to use.</param>
/// <param name="worker">The <see cref="System.ComponentModel.BackgroundWorker"/>worker to use.
/// </param>
public ThumbnailCreator(ThumbnailSettings tnSettings, System.ComponentModel.BackgroundWorker worker)
{
this._tnSettings = tnSettings;
this._worker = worker;
#if false
_imageCodec = GetEncoder (System.Drawing.Imaging.ImageFormat.Png);
_qualityParameter = new System.Drawing.Imaging.EncoderParameter (
System.Drawing.Imaging.Encoder.Quality, 75L);
_qualityParameters = new System.Drawing.Imaging.EncoderParameters (1);
_qualityParameters.Param[0] = _qualityParameter;
#else
_imageCodec = GetEncoder (System.Drawing.Imaging.ImageFormat.Jpeg);
_qualityParameter = new System.Drawing.Imaging.EncoderParameter (
System.Drawing.Imaging.Encoder.Quality, 75L);
_qualityParameters = new System.Drawing.Imaging.EncoderParameters (1);
_qualityParameters.Param[0] = _qualityParameter;
#endif
#if false
using (System.Drawing.Bitmap bitmap1 = new System.Drawing.Bitmap (1, 1))
{
System.Drawing.Imaging.EncoderParameters paramList =
bitmap1.GetEncoderParameterList (_imageCodec.Clsid);
System.Drawing.Imaging.EncoderParameter[] encParams = paramList.Param;
foreach (System.Drawing.Imaging.EncoderParameter p in encParams)
{
THelper.Information ("Type {0}, GUID {1}", p.ValueType, p.Encoder.Guid);
}
paramList.Dispose ();
}
#endif
}
示例5: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(422, 326);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// backgroundWorker1
//
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
//
// FMV
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(422, 326);
this.Controls.Add(this.pictureBox1);
this.Name = "FMV";
this.Text = "FMV";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FMV_FormClosing);
this.Load += new System.EventHandler(this.FMV_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
示例6: MyButton_Click
void MyButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (_worker != null)
{
_worker.CancelAsync();
_worker = null;
this.Content = _previousContent;
}
else if (MyOnClick != null)
{
_previousContent = this.Content;
_worker = new System.ComponentModel.BackgroundWorker();
_worker.WorkerSupportsCancellation = true;
_worker.WorkerReportsProgress = (MyOnProgress != null);
_worker.ProgressChanged += worker_ProgressChanged;
_worker.RunWorkerCompleted += worker_RunWorkerCompleted;
_worker.DoWork += delegate(object s, System.ComponentModel.DoWorkEventArgs args)
{
try
{
MyOnClick(this, _worker);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.ToString(), ex.Message);
}
};
this.Content = "Cancel";
_worker.RunWorkerAsync();
}
}
示例7: LoginWindow
public LoginWindow()
{
InitializeComponent();
this.loginBackgroundWorker = new System.ComponentModel.BackgroundWorker();
this.loginBackgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(loginBackgroundWorker_DoWork);
this.loginBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(loginBackgroundWorker_RunWorkerCompleted);
}
示例8: InitializeListener
public void InitializeListener()
{
SocketWorker = new System.ComponentModel.BackgroundWorker();
SocketWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.SocketWorker_DoWork);
Listener = new Listener();
Listener.OnReceiveCommand += Listener_OnReceiveCommand;
}
示例9: B_BaseBot
public B_BaseBot(String module_name, bool active = true)
{
this.module_name = module_name;
bw = new System.ComponentModel.BackgroundWorker();
bw.DoWork += new System.ComponentModel.DoWorkEventHandler(bw_DoWork);
if (active)
writeToMainLog("Module loaded!");
}
示例10: InitializeAgent
public void InitializeAgent()
{
AgentWorker = new System.ComponentModel.BackgroundWorker();
AgentWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.AgentWorker_DoWork);
Agent = new Agent();
Agent.OnCallStateChanged += Agent_OnCallStateChanged;
Agent.OnAccountStateChanged += Agent_OnAccountStateChanged;
}
示例11: TVDBLoader
public TVDBLoader(AbstractRepositoryFactory _repositories,
System.ComponentModel.BackgroundWorker _worker,
System.ComponentModel.DoWorkEventArgs _eventArgs)
{
repositories = _repositories;
worker = _worker;
eventArgs = _eventArgs;
}
示例12: MainWindow
public MainWindow()
{
m_game.AddSubscriber(this);
InitializeComponent();
worker = new System.ComponentModel.BackgroundWorker();
worker.DoWork += new System.ComponentModel.DoWorkEventHandler(DoWork);
}
示例13: CanTestContentsOfList
public void CanTestContentsOfList()
{
var worker = new System.ComponentModel.BackgroundWorker();
var list = new System.Collections.Generic.List<int>();
worker.RunWorkerCompleted += delegate { list.Add(1); };
worker.DoWork += delegate { Thread.Sleep(1); };
worker.RunWorkerAsync();
Assert.That(list, Has.Count.EqualTo(1).After(5000, 100));
}
示例14: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.backgroundWorker = new System.ComponentModel.BackgroundWorker();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.label = new System.Windows.Forms.Label();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// backgroundWorker
//
this.backgroundWorker.WorkerReportsProgress = true;
this.backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker_DoWork);
this.backgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker_ProgressChanged);
this.backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker_RunWorkerCompleted);
//
// progressBar
//
this.progressBar.Location = new System.Drawing.Point(13, 43);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(483, 18);
this.progressBar.TabIndex = 0;
//
// label
//
this.label.Location = new System.Drawing.Point(13, 9);
this.label.Name = "label";
this.label.Size = new System.Drawing.Size(483, 16);
this.label.TabIndex = 1;
this.label.Text = "Please wait for the task to complete.";
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(206, 73);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// BackgroundWorkerDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(508, 108);
this.ControlBox = false;
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.label);
this.Controls.Add(this.progressBar);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "BackgroundWorkerDialog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = " Cinar Database Tools";
this.TopMost = true;
this.ResumeLayout(false);
}
示例15: AddUser
public AddUser()
{
InitializeComponent();
bw = new System.ComponentModel.BackgroundWorker();
bw.WorkerReportsProgress = true;
bw.RunWorkerCompleted += bw_RunWorkerCompleted;
bw.DoWork += bw_DoWork;
bw.ProgressChanged += bw_ProgressChanged;
}