如何在VB.Net中的一种解决方案下在多个项目中使用线程 [英] How to use thread in Multiple project under one solution in VB.Net
问题描述
我正在一个解决方案下从事多个项目.
一个包含表单的项目( USERFORM )和另一个项目( Operation )具有所有类.在类中,使用while循环将值一个接一个地插入数据库.将每条记录插入数据库后,它会向其他项目(USERFORM)中的表单显示消息.
简而言之,我必须在while循环之间将消息从操作项目发送回USERFORM项目.
请帮我怎么做.
问候
Vikas
Hi,
I am working on multiple project under one solution.
One project(USERFORM) containing the forms and other project(Operation) is having all the classes. In classes, using while loop for inserting values into database one by one. After inserting each record in Database it shows the message to the Forms which in other project(USERFORM).
In short I have to sent back the message from Operation Project to USERFORM project in between while loop.
Please help me how to do this.
Regards
Vikas
推荐答案
很简单:在您的类中创建一个事件,该事件在循环中发出信号,该表单可以预订. MSDN [
It''s simple: Create an event in your class which you signal in your loop, and that the form can subscribe to. MSDN[^] has full instructions on how to do this.
您需要通过阻塞另一个线程来限制一个线程,以使用阻塞队列将一些任务"提供给该线程.
请在此处查看我的提示/技巧文章:用于线程通信和线程间调用 [ ^ ].它带有完整的源代码和用法示例.
—SA
You need to throttle one thread by another one to feed some "tasks" to it using a blocking queue.
Please see my Tips/Tricks article here: Simple Blocking Queue for Thread Communication and Inter-thread Invocation[^]. It''s complete with full source code and usage example.
—SA
这篇关于如何在VB.Net中的一种解决方案下在多个项目中使用线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!