프로그래밍언어/VB.NET

비동기 VB.NET _ Await

부산딸랑이 2013. 7. 7. 22:04

http://msdn.microsoft.com/en-us/library/vstudio/hh156570.aspx

Imports System.Threading

'이렇게 쓰면 UI가 멈춤

 Private Async Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim result As String = Await WaitSynchronously()

        TextBox1.Text &= result

    End Sub

Public Async Function WaitSynchronously() As Task(Of String)

        ' Import System.Threading for the Sleep method.

        Thread.Sleep(5000)

        Return "Finished"

    End Function


'이렇게 쓰면 안멈춤

Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        ' Call the method that runs asynchronously.

        Dim result As String = Await WaitAsynchronouslyAsync()

        TextBox1.Text &= result

    End Sub

   Public Async Function WaitAsynchronouslyAsync() As Task(Of String)

        Await Task.Delay(5000)

        Return "Finished"

    End Function

'프로그래밍언어 > VB.NET' 카테고리의 다른 글

VB.NET 동적컨트롤 생성  (0) 2013.07.10
비베 속도향상 팁 45가지   (0) 2013.07.09
비베로 오토핫키처럼 이미지비교..  (0) 2013.07.07
WinHTTP vs HTTPWebrequest vs XMLHTTP  (0) 2013.07.07
INET vs WINHTTP  (0) 2013.07.07