首页 \ 问答 \ 背景工作者(Background worker)

背景工作者(Background worker)

如果我有一组操作,我想根据特定条件在后台工作程序中运行,例如,我有10个条件

if(a)
    BackgroundWorker doA = new backgroundworker()
if(b) 
    BackgroundWorker doB = new backgroundworker()
if(c) 
    BackgroundWorker doC = new backgroundworker()
if(d) 
    BackgroundWorker doD = new backgroundworker()
...
...

每个后台工作人员都需要一个dowork,runworkercompleted等....无论如何都要避免这样做,因此它会使代码变得不那么混乱/污染,因为其中一些方法可能会很大?

谢谢


If i have a set of actions i want to run in a background worker based on a certain condition and i have 10 conditions, for example

if(a)
    BackgroundWorker doA = new backgroundworker()
if(b) 
    BackgroundWorker doB = new backgroundworker()
if(c) 
    BackgroundWorker doC = new backgroundworker()
if(d) 
    BackgroundWorker doD = new backgroundworker()
...
...

each of those background workers will require a dowork, runworkercompleted etc.... is there anyway to avoid that so it makes the code less messy/clutered as some of those methods might be quite big?

thanks


原文:https://stackoverflow.com/questions/5538372
更新时间:2022-08-29 08:08

最满意答案

您是否尝试将node_modules添加到.gitignore文件并检查gitignore文件?

我假设Heroku抱怨,因为它试图安装node_modules但它已经在同一位置看到名为node_modules的文件夹。


Did you try adding node_modules to your .gitignore file and checking in the gitignore file?

I am assuming Heroku is complaining because it's trying to install the node_modules but it already sees a folder called node_modules in the same location.

相关问答

更多
  • 经过大量的故障排除后,我终于找到了它的底部。 heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git 在根目录中创建一个名为.buildpacks的文件,并添加以下https://github.com/heroku/heroku-buildpack-nodejs.git https://github.com/heroku/heroku-buildpack-ruby.git 在根目录中创建一个名 ...
  • 我的解决方案是在服务器上从头开始安装流程,如果它不存在.... My solution was to install the process from scratch on the server if it didn't exist....
  • 这里是解析Gemfile的错误:语法错误,意外的':',期待输入结束 - 组:生产 如上面的日志...这只是语法错误 group: production do gem 'pg' gem 'rails_12factor' end 从它更新 group :production do gem 'pg' gem 'rails_12factor' end here was an error parsing Gemfile: syntax error, unexpected ':', expecti ...
  • 我认为这是一个在root帐户下运行npm的问题,这是不鼓励的。 为了在没有sudo标志的情况下运行所有的计算机npm,可以为nvm安装nvm 。 它允许您拥有许多节点版本,并且可以在不使用root帐户(sudo命令)的情况下安装 - --global软件包。 你可以安装他们的官方脚本来安装它: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash nvm回购: https : //github. ...
  • 您是否尝试将node_modules添加到.gitignore文件并检查gitignore文件? 我假设Heroku抱怨,因为它试图安装node_modules但它已经在同一位置看到名为node_modules的文件夹。 Did you try adding node_modules to your .gitignore file and checking in the gitignore file? I am assuming Heroku is complaining because it's tryi ...
  • 似乎反应入门工具包默认情况下不会作为生产运行,并且buildpack 将环境设置为生产环境 。 我相信你可以在项目中添加一个Procfile ,告诉它作为生产开始,或者只是将Heroku环境设置为开发 。 如果您在错误时发布Heroku日志,我们可以看到它的更多细节。 It seems that the react starter kit doesn't run as production by default, and the buildpack sets the environment to produ ...
  • 你应该删除gemfile开发组之外的行gem 'sqlite3', '1.3.8' 。 并移动开发组中的sqlite3引用以包括测试组: group :development, :test do gem 'sqlite3', '1.3.8' end 问题是heroku使用PostgreSQL,当你部署时,它试图使用sqlite3 gem,因为它在开发组之外以及在其中。 You should remove the line gem 'sqlite3', '1.3.8' that is outside t ...
  • 你在使用premailer-rails3 gem吗? 我发现版本1.2.0导致了同样的问题。 降级至1.1.0修正了它。 希望有所帮助! Are you using the premailer-rails3 gem? I found that version 1.2.0 caused this exact same problem. Downgrading to 1.1.0 fixed it. Hope that helps!
  • 这里的问题是你使模型类成为可注射的 。 @Injectable() export class RatingModel { 你不必将模型类设为可注射的。 如果您确实需要这样做,则必须将其设置为提供者。 或者尝试从显式注入器中获取对象。 constructor(private injector: Injector) { } //.. this.ratingModel = this.injector.get(RatingModel) The problem here is you are making ...
  • 你的项目中只有错误的路径。 在Heroku上,您无法写入项目根目录下的文件夹。 在您的情况下,您的代码在app.js运行,该app.js位于项目的“root”文件夹中。 因此,在Heroku的文件系统上,这意味着您的项目如下所示: /app /app/app.js /app/public /app/public/images ... Heroku将您的所有代码放入名为app的文件夹中。 现在,在上面粘贴的代码中,您显示: Request(uri).pipe(fs.createWriteStream(__d ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。