本文整理汇总了C#中System.ComponentModel.BackgroundWorker.RunWorkerAsync方法的典型用法代码示例。如果您正苦于以下问题:C# BackgroundWorker.RunWorkerAsync方法的具体用法?C# BackgroundWorker.RunWorkerAsync怎么用?C# BackgroundWorker.RunWorkerAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.BackgroundWorker
的用法示例。
在下文中一共展示了BackgroundWorker.RunWorkerAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseTopPerson
public static void ParseTopPerson(string html, Action<List<Person>> finished)
{
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler((sender, e) =>
{
List<Person> TopPerson = new List<Person>();
HtmlDocument hDoc = new HtmlDocument();
hDoc.LoadHtml(html);
var tableRows = hDoc.DocumentNode.SelectNodes(Constants.Instance.XPATH_GAME_TOP_RESULT);
foreach (var node in tableRows)
{
var results = ChildElementsInTableRow(node);
if (results.Count == Constants.Instance.COUNT_GAME_TOP_RESULT_COLUMNS)
{
var person = TopPersonFromStrings(results);
if (person.Total != 0)
{
TopPerson.Add(person);
}
}
}
finished(TopPerson);
});
bw.RunWorkerAsync();
}
示例2: ParseRecommends
public static void ParseRecommends(string html, Action<List<Recommend>> finished)
{
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler((sender, e) =>
{
List<Recommend> allRecommends = new List<Recommend>();
HtmlDocument hDoc = new HtmlDocument();
hDoc.LoadHtml(html);
var tableRows = hDoc.DocumentNode.SelectNodes(Constants.Instance.XPATH_GAME_SHOW_RESULT);
foreach (var node in tableRows)
{
var results = ChildElementsInTableRow(node);
if (results.Count == Constants.Instance.COUNT_GAME_SHOW_RESULT_COLUMNS)
{
var rec = RecommendFromStrings(results);
if (IsValidRecommend(rec))
{
allRecommends.Add(rec);
}
}
}
finished(allRecommends);
});
bw.RunWorkerAsync();
}
示例3: btVolDoc_Click
private void btVolDoc_Click(object sender, EventArgs e)
{
worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(VolDocAsync);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(VolDocAsyncCompleta);
btVolDoc.Text = "Pesquisando";
btVolDoc.Enabled = false;
if (radioMatriz.Checked) // Matriz
{
query = "SELECT trim(trf_ref) || trf_ser as serie from transferido where trf_vol = '"+ numericDoc.Value+ "' and trf_dtc is null and ROWNUM <= 500 order by trf_ser";
//Console.WriteLine(query);
worker.RunWorkerAsync();
}
else // Filial
{
if(intFilial.Value != 0) // Não é filial 0
{
// query = "SELECT mov_ser as serie from movimento where mov_doc = '" + numericDoc.Value + "' and mov_sed ='" +intFilial.Value + "' and ROWNUM <= 500";
query = "SELECT trim(mov_ref) || mov_ser as mercadoria from movimento where mov_doc = '" + numericDoc.Value + "' and mov_sed ='" + intFilial.Value + "'";
worker.RunWorkerAsync();
}
else
{
MessageBox.Show("Precisa selecionar uma filial");
btVolDoc.Text = "Pesquisar";
btVolDoc.Enabled = true;
}
}
}
示例4: NetworkClient
public NetworkClient(System.Net.IPAddress serverAddress, int port)
{
TcpClient client = new TcpClient();
client.Connect(serverAddress, port);
_stream = client.GetStream();
_connected = true;
BackgroundWorker streamWorker = new BackgroundWorker();
streamWorker.WorkerSupportsCancellation = true;
streamWorker.DoWork += ReadFromStream;
streamWorker.RunWorkerCompleted += (s, a) =>
{
if (_connected)
{
streamWorker.RunWorkerAsync(_stream);
}
};
streamWorker.RunWorkerAsync(_stream);
StreamError += (ex, stream) =>
{
if (ex is IOException || ex is InvalidOperationException || ex is ObjectDisposedException)
{
_connected = false;
Console.WriteLine("Lost connection: {0}", ex.Message);
Console.Write("> ");
}
else
{
throw ex;
}
};
}
示例5: MainWindow
public MainWindow()
{
string[] args = Environment.GetCommandLineArgs();
InitializeComponent();
string[] validUsers = { "usernames" };//update to run
string strUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
int indDomain = strUserName.LastIndexOf("\\")+1;
string user = strUserName.Substring(indDomain, strUserName.Length - indDomain);
int i = args.Count();
if (true) { //update for validuser check
BackgroundWorker bw1 = new BackgroundWorker();
if (args.Count() > 1) {
string fileName = args[1];
bw1.DoWork += new DoWorkEventHandler(updateFromFile);
bw1.RunWorkerAsync(fileName);
initBtn.IsEnabled = false;
updateBtn.IsEnabled = false;
pBar.Visibility = Visibility.Hidden;
} else {
bw1.DoWork += new DoWorkEventHandler(getPList);
bw1.RunWorkerAsync();
initBtn.IsEnabled = false;
updateBtn.IsEnabled = false;
pBar.Visibility = Visibility.Hidden;
}
} else {
initBtn.IsEnabled = false;
updateBtn.IsEnabled = false;
status.Content = "Not an allowed user, contact SCT.";
pBar.Visibility = Visibility.Hidden;
}
//status.Content = strUserName;
}
示例6: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
_serverProcessor = new ServerProcessor();
_serverProcessor.MessageReceived += _serverProcessor_MessageReceived;
BackgroundWorker bg = new BackgroundWorker();
bg.DoWork += delegate { _serverProcessor.RunServer(); };
bg.RunWorkerCompleted += delegate { bg.RunWorkerAsync(); };
bg.RunWorkerAsync();
}
示例7: ServerForm_Load
private void ServerForm_Load(object sender, EventArgs e)
{
_bg = new BackgroundWorker();
_bg.DoWork += delegate { _processor.Initialize(); };
_bg.RunWorkerCompleted += delegate { _bg.RunWorkerAsync(); };
_bg.RunWorkerAsync();
this.Text += " " + _processor.ServerDetails;
NotifyIconServer.Text = _processor.ServerDetails;
WindowState = FormWindowState.Minimized;
}
示例8: CreateDictionaryHash
public void CreateDictionaryHash()
{
var prefixTreeThread = new BackgroundWorker();
prefixTreeThread.DoWork += ReadPrefixTree;
prefixTreeThread.RunWorkerCompleted += ReadPrefixTreeComplete;
prefixTreeThread.RunWorkerAsync();
}
示例9: UpdateCheck
private static void UpdateCheck()
{
Game.PrintChat("<font color='#33FFFF'>>>LeagueSharp.Common loaded <<");
var bgw = new BackgroundWorker();
bgw.DoWork += bgw_DoWork;
bgw.RunWorkerAsync();
}
示例10: UpdateCheck
private static void UpdateCheck()
{
Game.PrintChat("<font color='#33FFFF'> .: Orianna by trelli loaded :.");
var bgw = new BackgroundWorker();
bgw.DoWork += bgw_DoWork;
bgw.RunWorkerAsync();
}
示例11: btnLoadData_Click
private void btnLoadData_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog dlgFolder = new FolderBrowserDialog())
{
if (dlgFolder.ShowDialog() == DialogResult.OK)
{
for (int i = 0; i < this.feretDataSet.faces.Rows.Count; i++)
{
this.feretDataSet.faces.Rows[i].Delete();
}
updateDatabase();
BackgroundWorker worker = new BackgroundWorker();
worker.WorkerReportsProgress = true;
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
worker.RunWorkerAsync(dlgFolder.SelectedPath);
lstInfo.Enabled = false;
//lstSelect.Enabled = false;
btnLoadData.Enabled = false;
btnSaveSetList.Enabled = false;
dataGridView1.Enabled = false;
}
}
}
示例12: Start
/// <summary>
/// Lance une tache dans un background worker.
/// </summary>
/// <param name="taskFunc">Tache à exécuter.</param>
/// <param name="completionAction">Action à réaliser après l'exécution. Recoit l'exception si une exception a eu lieu.</param>
public static void Start(Action taskFunc, Action<Exception> completionAction)
{
if (taskFunc == null)
{
throw new ArgumentNullException("taskFunc");
}
var backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(
delegate
{
taskFunc();
});
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
delegate(object sender, RunWorkerCompletedEventArgs e)
{
if (completionAction != null)
{
completionAction(e.Error);
}
});
backgroundWorker.RunWorkerAsync();
}
示例13: Twitch
public Twitch(string channel, string ircAdress, int port) {
smiles = new Dictionary<string, TwitchSmile>();
channelName = channel.Trim().ToLower();
ircUrl = ircAdress;
this.port = port;
BackgroundWorker bg = new BackgroundWorker();
bg.DoWork += bg_DoWork;
bg.RunWorkerAsync();
regexSignsEmotions = new string[]{"B-?\\)",
"\\:-?[z|Z|\\|]",
"\\:-?\\)",
"\\:-?\\(",
"\\:-?(p|P)",
"\\;-?(p|P)",
"\\<\\;3",
"\\:-?(?:\\/|\\\\)(?!\\/)",
"\\;-?\\)",
"R-?\\)",
"[o|O](_|\\.)[o|O]",
"\\:-?D",
"\\:-?(o|O)",
"\\>\\;\\(",
"\\:\\>\\;",
"\\:-?(S|s)",
"#-?[\\\\/]",
"\\<\\;\\]",
":-?(?:7|L)"};
}
示例14: RefreshAllAsync
public override void RefreshAllAsync()
{
BackgroundWorker refreshAllWorker = new BackgroundWorker();
refreshAllWorker.DoWork += new DoWorkEventHandler(RefreshWorker_DoWork);
refreshAllWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RefreshWorker_RunWorkerCompleted);
refreshAllWorker.RunWorkerAsync();
}
示例15: RunAsync
public void RunAsync()
{
worker = new BackgroundWorker();
worker.DoWork += OnMethodStarted;
worker.RunWorkerCompleted += OnMethodFinished;
worker.RunWorkerAsync();
}