可以使用后台工作人员执行繁重的任 [英] Can use background worker for heavy task?

查看:86
本文介绍了可以使用后台工作人员执行繁重的任的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将超过50 k的记录从一个DB移动到另一个DB以用于多个数据库。我正在使用调度程序来调用后台工作程序



我正在考虑使用后台工作程序任何人都可以告诉我哪个是此任务的最佳过程?



我尝试了什么:



我正在使用调度程序来调用后台工作者



我在想使用后台工作人员可以告诉我哪个是这个任务的最佳流程吗?

解决方案

A后台工作者很好 - 但是它的名字暗示了一些不正确的东西:它没有比普通线程更低的优先级运行,它是一个普通的线程,当所有前台线程都退出时会自动关闭(所以你的app不必担心清理它背后的线程。)



如果你想在后台运行CPU密集型操作,你可能会更好用一个普通的Thread对象,并自己设置优先级:Thread.Priority Property(System.Threading) [ ^ ]。

如果您的应用程序需要退出,这将使您负责关闭该线程,但无论如何,这可能是一个好主意,以确保您在线程被自动杀死之前知道每个操作都已完成。 / BLOCKQUOTE>

I need to Move more than 50 k Records from one DB to another DB for multiple Databases. I am using scheduler to call Background Worker

I am thinking to use background Worker Can any one tell me which is best process for this task?

What I have tried:

I am using scheduler to call Background Worker

I am thinking to use background Worker Can any one tell me which is best process for this task?

解决方案

A background worker is good - but it's name suggests something that isn't true: it doesn't run at a lower priority than normal threads, it is a normal thread that will be automatically closed automatically when all foreground threads have exited (so your app doesn't have to worry about cleaning up threads behind it).

If you want to run a CPU intensive operation in the background, you would probably be better off using a regular Thread object, and setting the priority on that yourself: Thread.Priority Property (System.Threading)[^].
That will make you responsible for closing the thread if your app needs to exit, but that's probably a good idea anyway to ensure that you "know" that each operation is complete before your thread is automatically killed.


这篇关于可以使用后台工作人员执行繁重的任的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆