如何创建批处理文件并使用 C# 线程同时执行它们

发布于 2024-08-28 14:22:58 字数 184 浏览 8 评论 0原文

我有大约 4000 行的数据库代码。大约需要30-40分钟。用于执行。

我想创建 20 个包含相同命令行的批处理文件,以便我可以使用线程同时启动它们。

所有批处理文件都不依赖于其他批处理文件。都是独立的。唯一的依赖是全部将在同一个数据库上执行。

任何人都可以指导我应该如何进行,以便减少通常执行所需的时间。

I have code for Database which is about of 4000 lines. It takes around 30 40 min. for executing.

I want to create 20 batch files containing equal lines of command so that I can start them at same time using thread.

None of the batch files are dependent on other. All are independent. Only dependency is all will execute on same database.

Can anyone please guide me how should I proceed so that the time it normally takes to execute is reduced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

变身佩奇 2024-09-04 14:22:58

1)并行运行一系列命令并不总是更快。

2)要并行运行它们,您不需要批处理文件。查看线程或线程池。

3) 要使用批处理文件,请将内容写入(临时)文件并使用 System.Diagnostics.Process 类执行它。

1) running a series of commands in parallel will not always be faster.

2) to run them in parallel, you don't need batch files. Take a look at Threads or the ThreadPool.

3) To use batch files, write the contents to a (temp) file and execute it using the System.Diagnostics.Process class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文