使用多线程创建多个数据库的备份 [英] Creating backup of several databases using multithreading

查看:206
本文介绍了使用多线程创建多个数据库的备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试纠正VB.NET代码以创建多个数据库的备份.
备份过程(已编写)要求服务器,数据库名和备份文件名,并在备份完成后返回字符串(成功"或错误").

因为每个备份可能要花费几分钟,并且由于数据库可以位于不同的服务器上,所以最好在单独的线程中创建备份.

我已经知道如何使用多个线程,以及如何等待所有线程完成,但是如何将服务器参数,数据库en文件名传递给线程,以及如何读取返回字符串? >

I''m trying to right VB.NET code to create backups of several databases.
The backup-procedure (already written) asks for server, databasename and backup-filename, and returns a string ("Success" or "Error") after backup has been made.

Because each backup can take several minutes, and because the databases can be located on different servers, it is better to create the backups in separated threads.

I already know how to work with multiple threads, and how to wait for all threads to finish, but how can I pass the arguments of server, database en filename to the thread, and how can I read the return-string ?

Thanks already !

推荐答案

您可以使用事件,参数化的线程启动以及.NET提供的其他多线程技术
You can use events, parametrized thread-starts and other multi-threading techniues offered by .NET


一种方法是编写一个包装线程的类.该类将具有输入和输出字段的成员属性,并将公开足够的Thread对象以启用同步和控制.线程main方法将是该类的成员,因此可以访问实例属性.

尼克
One way would be to write a class that wraps a thread. The class would have member properties for the input and output fields and would expose enough of the Thread object to enable synchronization and control. The thread main method would be a member of the class and so would have access to the instance properties.

Nick


这篇关于使用多线程创建多个数据库的备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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