多线程概念 [英] Multiple threading concept

查看:77
本文介绍了多线程概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试在VB vode中实现线程概念。我想使用3个线程执行操作。一个线程用于更新函数,第二个线程是将从函数收集的数据更新到服务器,第三个线程是从
获取数据服务器并显示。这是主要的想法。是否有可用于此类操作的代码段。



thread1 = New System.Threading.Thread(AddressOf updatefun)thread.Start()


< span style ="background-color:#fafafa; font-family:Verdana,Arial,Helvetica,sans-serif; white-space:pre"> thread2 = New System.Threading.Thread(AddressOf
updatechart)thread.Start()


试试¥b $ b  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; thread1.Join()

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; thread2.Join()

  &NBSP; &NBSP; &NBSP;赶上例外情况

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(e.ToString())

  &NBSP; &NBSP; &NBSP;最后是
  &NBSP; &NBSP; &NBSP;结束尝试

我正在尝试这样的示例代码用于2个threads.one用于函数另一个用于显示。


问候


B Teja




B TEJA

解决方案

您描述的是典型的串行过程。它可以完成(但在某种程度上它是真正避免错误,非常困难。另一个问题是处理时间将是线程(异步)方式的倍数。 


然而,更糟糕的是,对于您的流程,最终用户会看到类似这样的内容。 



如果你想使用异步而不是使用更简单的过程。


https://stackify.com/when-to-use-asynchronous-programming/


Hi,

I am trying to implement the threading concept in VB vode. I want to perform the operation using 3 threads. One thread for updating the function, Second thread is to update the data collected from the function to server, Third thread is to get the data from the server and display. This is the main idea. Is there any code snippet available for this type of operation.

thread1 = New System.Threading.Thread(AddressOf updatefun) thread.Start()

thread2 = New System.Threading.Thread(AddressOf updatechart) thread.Start()

Try
            thread1.Join()
            thread2.Join()
        Catch e As Exception
            Console.Write(e.ToString())
        Finally
        End Try

I'm trying with the example code like this for 2 threads.one for function the other for display.

Regards

B Teja


B TEJA

解决方案

What you describe is a typical serial process. It can be done (but in a way it is real avoiding errors, very difficult. Another problem is that the process time will be a multiple of the a threading (async) way. 

However, worse is that with your process the end user sees something like this. 

If you want to use async than use a more simple processes.

https://stackify.com/when-to-use-asynchronous-programming/


这篇关于多线程概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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