backgroundworker

OSX keyboard shortcut background application, how to

假装没事ソ 提交于 2019-11-28 20:45:03
I want my OSX application to sit in the background and wait for a keyboard shortcut to go into action. It should be configurable similar to Growl in the preferences, or accessible as dropbox in the statusbar. What kind of xcode template do I have to use? How do I capture keyboard shortcuts globally? Have a look at Dave DeLong's DDHotKey class on GitHub. DDHotKey is an easy-to-use Cocoa class for registering an application to respond to system key events, or "hotkeys". A global hotkey is a key combination that always executes a specific action, regardless of which app is frontmost. For example,

How is BackgroundWorker.CancellationPending thread-safe?

末鹿安然 提交于 2019-11-28 19:20:25
The way to cancel a BackgroundWorker's operation is to call BackgroundWorker.CancelAsync() : // RUNNING IN UI THREAD private void cancelButton_Click(object sender, EventArgs e) { backgroundWorker.CancelAsync(); } In a BackgroundWorker.DoWork event handler, we check BackgroundWorker.CancellationPending : // RUNNING IN WORKER THREAD void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { while (!backgroundWorker.CancellationPending) { DoSomething(); } } The above idea is all over the web, including on the MSDN page for BackgroundWorker . Now, my question is this: How on earth is this

What's the best way to organize worker processes in Rails?

丶灬走出姿态 提交于 2019-11-28 18:15:36
问题 I frequently have some code that should be run either on a schedule or as a background process with some parameters. The common element is that they are run outside the dispatch process, but need access to the Rails environment (and possibly the parameters passed in). What's a good way to organize this and why? If you like to use a particular plugin or gem, explain why you find it convenient--don't just list a plugin you use. 回答1: For me, not wanting to maintain a lot of extra infrastructure

Windows Service that runs Periodically

橙三吉。 提交于 2019-11-28 17:04:47
I'm writing a windows service that once started will run every X hours. The process it completes is fairly intensive, so I want to use a background worker. I'm using a Settings file to store both the hours between runs and the last time the service ran. I'm not exactly sure the best way to do this - that is, I want the service to idle using as few resources as possible, and when it runs, it needs to run in the background worker, report what it did, and then go back into idle mode. I've thought about using 2 background workers. The first worker would be a private local variable for the service

polling with delayed_job

前提是你 提交于 2019-11-28 15:44:22
I have a process which takes generally a few seconds to complete so I'm trying to use delayed_job to handle it asynchronously. The job itself works fine, my question is how to go about polling the job to find out if it's done. I can get an id from delayed_job by simply assigning it to a variable: job = Available.delay.dosomething(:var => 1234) +------+----------+----------+------------+------------+-------------+-----------+-----------+-----------+------------+-------------+ | id | priority | attempts | handler | last_error | run_at | locked_at | failed_at | locked_by | created_at | updated_at

Winforms updates with high performance

谁都会走 提交于 2019-11-28 14:34:03
Let me setup this question with some background information, we have a long running process which will be generating data in a Windows Form. So, obviously some form of multi-threading is going to be needed to keep the form responsive. But, we also have the requirement that the form updates as many times per second while still remaining responsive. Here is a simple test example using background worker thread: void bw_ProgressChanged(object sender, ProgressChangedEventArgs e) { int reportValue = (int)e.UserState; label1.Text = reportValue; //We can put this.Refresh() here to force repaint which

BackgroundWorker completes before DoWork

大憨熊 提交于 2019-11-28 14:31:18
I'm using a background worker to handle the loading of a file to stop my ui from freezing however it seems that the RunWorkerCompleted is finishing before my DoWork event has completed (Causes errors when exiting dialog)... is there anything I'm doing wrong? Am I better off doing this over a task? public static <T> LoadDesign(string xmlPath) { PleaseWait pw = new PleaseWait(xmlPath); pw.ShowDialog(); return pw.design; } private PleaseWait(string xmlFile) { InitializeComponent(); bw = new BackgroundWorker(); bw.WorkerSupportsCancellation = true; bw.DoWork += (s, e) => { design = (Cast)DllCall

Calling ShowDialog in BackgroundWorker

人走茶凉 提交于 2019-11-28 13:33:36
I have a WinForms application in which my background worker is doing a sync task, adding new files, removing old ones etc. In my background worker code I want to show a custom form to user telling him what will be deleted and what will be added if he continues, with YES/NO buttons to get his feedback. I was wondering if it is ok to do something like this in background worker's doWork method? If not, how should I do it? Please advise.. private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { MyForm f = new MyForm(); f.FilesToAddDelete(..); DialogResult result = f.ShowDialog();

How to use BackgroundWorker in C#

放肆的年华 提交于 2019-11-28 12:54:55
How to use BackgroundWorker in C#? Actually i'm performing an operation of filling a PDF-Form from method called fill() . It takes more time to show up the result into pdfviewer, so I decided to show up a 'processing image' using a backgroundworker, and tried using it but failing to achieve it here is my code snippet : private void bgwLoadFile_DoWork(object sender, DoWorkEventArgs e) { this.Invoke((MethodInvoker)delegate() { ???? }); } private void bgwLoadFile_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled == true) { } else if (e.Error != null) { } else {

Adding 150,000 records to a listview without freezing UI

我的梦境 提交于 2019-11-28 12:49:52
I have a listview loop that is adding 150,000 items to my listview. For testing purposes I moved this code to a background worker with delegates, but it still freezes up the UI. I am trying to find a solution so that it can add these items in the background while I do other stuff in the app. What solutions do you guys recommend? this is what I am using Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ListView1.Clear() ListView1.BeginUpdate() bw.WorkerReportsProgress = True bw.RunWorkerAsync() End Sub Private Sub Button2_Click(sender As Object