当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Thread.Suspend方法代码示例

本文整理汇总了VB.NET中System.Threading.Thread.Suspend方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Thread.Suspend方法的具体用法?VB.NET Thread.Suspend怎么用?VB.NET Thread.Suspend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Thread的用法示例。


在下文中一共展示了Thread.Suspend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Module1

' 导入命名空间
Imports System.Threading

Module Module1

    Public A As Thread = New Thread(AddressOf MethodA)
    Public B As Thread = New Thread(AddressOf MethodB)
    Public C As Thread = New Thread(AddressOf MethodC)

    Sub MethodA()
        Dim I As Integer
        Try
            A.Suspend()
            For I = 0 To 250
                Console.Write("A")
            Next
        Catch E As ThreadStateException
            Console.WriteLine("Thread A Expection" & E.ToString())
        End Try

    End Sub

    Sub MethodB()
        Dim I As Integer
        Try
            For I = 0 To 250
                Console.Write("B")
            Next
        Catch E As ThreadAbortException
            Console.Write("Thread B has been aborted")
        End Try

    End Sub

    Sub MethodC()
        Dim I As Integer

        Try
            If (B.IsAlive) Then
                B.Abort()
            End If

            For I = 0 To 250
                If (A.ThreadState = ThreadState.Suspended) Then
                    A.Resume()
                End If

                Console.Write("C")
            Next
        Catch E As Threading.ThreadStateException
            Console.WriteLine("Thread C Expection" & E.ToString())
        End Try
    End Sub

    Sub Main()
        A.Start()
        B.Start()
        C.Start()
    End Sub

End Module
开发者ID:VB程序员,项目名称:System.Threading,代码行数:61,代码来源:Thread.Suspend


注:本文中的System.Threading.Thread.Suspend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。