backgroundworker

Can a Heroku app add/remove dynos or workers to/from itself?

微笑、不失礼 提交于 2019-12-03 21:24:46
Heroku allows you to add and remove dynos and workers on the fly and charges you per second that each is used. Is it possible to set up my app so that it can add/remove dynos and workers from itself depending on the load it's under? This paragraph on Heroku.com mentions an API, but I can't find out much more about it. Yes. What you want is something like this: require 'heroku' Heroku::Client.new("username", "password").set_workers("appname", num_workers) 来源: https://stackoverflow.com/questions/3039639/can-a-heroku-app-add-remove-dynos-or-workers-to-from-itself

WPF: How to handle errors with a BackgroundWorker

泪湿孤枕 提交于 2019-12-03 20:41:15
I am a bit of a newbie when it comes to windows client programming. I have a background worker that has a DoWork event and a RunCompleted event wired up. If an exception gets thrown in DoWork, I want to make changes to my UI, however, I cant because it is in a different thread. I can communicate the error to RunCompleted, but that doesn't help me either. call Dispatcher.BeginInvoke. Basically, you want code like this: void UpdateState(WhatEverType someObject) { if (! Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(()=>UpdateState(someObject)); } else {

Changing the property of a control from a BackgroundWorker C#

一个人想着一个人 提交于 2019-12-03 17:06:34
I'm trying to load a bunch of files from a directory, and while it's loading, display a progress bar status, as well as a label that displays which file is being processed. private void FileWorker_DoWork(object sender, DoWorkEventArgs e) { for (int i = 0; i < Files.Length; i++) { Library.AddSong(Files[i]); FileWorker.ReportProgress(i); } } At the moment it processes everything properly, and the progress bar displays status properly, but when i try to change the label's text (lblfile.text) it says it cannot change a control on a different thread. Is there a way to change the text of lblfile

cancel background worker exception in e.result

僤鯓⒐⒋嵵緔 提交于 2019-12-03 16:51:45
i have a serious problem with background worker. code is working if task is ending regular. when i cancel the background task i get an system.invalidoperationexception in the RunWorkerCompleted function for e.Result. what is wrong? thank you. here is my cod: private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (backgroundWorker.CancellationPending == true) e.Cancel = true; e.Result = resultList; } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) List<Object> resultList = (List<Object>)e.Result; } This

File.Exists() returns false, but not in debug

时间秒杀一切 提交于 2019-12-03 16:45:27
I'm being completely confused here folks, My code throws an exception because File.Exists() returns false public override sealed TCargo ReadFile(string fileName) { if (!File.Exists(fileName)) { throw new ArgumentException("Provided file name does not exist", "fileName"); } Visual studio breaks at the throw statement, and I immediately check the value of File.Exists(fileName) in the immediate window. It returns true . When I drag the breakpoint back up to the if statement and execute it again, it throws again. fileName is an absolute path to a file. I'm not creating the file, nor writing to it

TwainDotNet Scanning using TWAIN with BackgroundWorker

情到浓时终转凉″ 提交于 2019-12-03 16:44:41
Has anyone tried TwainDotNet for scanning with TWAIN API calls from .NET? Though it works well usually I've some issues with it when used along with WPF application using MVVM. Basically I'm calling Twain scanning functions from a Service, which in turn uses a BackgroundWorker. List<BitmapSource> bitmapSources = new List<BitmapSource>(); Twain twain = new Twain(new WpfWindowMessageHook(_window)); ScanSettings settings = new ScanSettings() { ShowTwainUI = false }; using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += (sndr, evnt) => { AutoResetEvent waitHandle = new

The right way to implement a progressbar in C#

江枫思渺然 提交于 2019-12-03 16:41:22
I'm learning winforms and I have set myself a simple goal of making a progressbar that goes from empty to full. Here's my misshapen attempt: public partial class Form1 : Form { static BackgroundWorker bw = new BackgroundWorker(); public Form1() { InitializeComponent(); bw.DoWork += bw_DoWork; bw.RunWorkerAsync(); } void bw_DoWork(object sender, DoWorkEventArgs e) { for(int i=0; i<100; ++i) { progressBar1.PerformStep(); Thread.Sleep(10); } } } I'm pretty sure that the Thread.Sleep() is reprehensible. How do I avoid it here? You are already doing it almost right. The BackgroundWorker has a built

VB.net stopping a backgroundworker

筅森魡賤 提交于 2019-12-03 16:03:41
I want to create a button that could stop my background worker and end all the process it is working on. Here is my sample backgroundworker code: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try If BackgroundWorker1.IsBusy <> True Then BackgroundWorker1.RunWorkerAsync() End If Catch ex As Exception End Try End Sub Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Dim counter As Integer = 1 Do 'updated code with stop function---------------- BackgroundWorker1

WPF Dispatcher, Background worker and a whole lot of pain

ぃ、小莉子 提交于 2019-12-03 15:58:36
Ok this may be really simple but everything I try just seems to hit a brick wall. I have a view model with two properties, which are bound to my WPF form: bool IsWorking {get;set;} ObservableCollection<OtherViewModel> PendingItems {get;set;} I have a method that I call to fetch some new pending items from outlook, however I also what to show some sort of progress on the form(spinning progress bar), the progress bar visibility is bound to the IsWorking property on the ViewModel, and a grid is bound to PendingItems collection. I would like to be able to set the IsWorking to true so the UI can

Autoscaling workers for delayed_job in Rails 3

邮差的信 提交于 2019-12-03 14:04:55
问题 I've been using collectiveidea's fork of delayed_job as a gem in my Rails 3 app, and it's working fine. I'm now looking for a solution to autoscale workers, specifically for Heroku. I've given pedro's fork a try but since it's written for Rails 2, using it throws lots of errors and warnings about deprecated methods and I haven't been able to get it to work successfully. Is there a working solution for Rails 3 delayed_job with autoscaling workers? 回答1: You might want to take a look at workless