<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>產生非同步方法呼叫</Title>
      <Author>Microsoft Corporation</Author>
      <Description>使用 BackgroundWorker 元件產生非同步方法呼叫。</Description>
      <Shortcut>appAsynchMeth</Shortcut>
    </Header>
    <Snippet>
      <Imports>
        <Import>
          <Namespace>Microsoft.VisualBasic</Namespace>
        </Import>
        <Import>
          <Namespace>System.Threading</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Object>
          <ID>backgroundWorkerInstance</ID>
          <Type>System.ComponentModel.BackgroundWorker</Type>
          <ToolTip>管理背景執行緒的 BackgroundWorker 元件執行個體，由工具箱中拖曳 BackgroundWorker 元件執行個體即可建立。</ToolTip>
          <Default>BackgroundWorker1</Default>
        </Object>
      </Declarations>
      <Code Language="VB" Kind="method decl"><![CDATA[    Private Sub startBackgroundTask()
        ' Execute the Background Task
        $backgroundWorkerInstance$.RunWorkerAsync()
    End Sub

    Private Sub $backgroundWorkerInstance$_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles $backgroundWorkerInstance$.DoWork
        ' This method will execute in the background thread created by the BackgroundWorker componet

    End Sub

    Private Sub $backgroundWorkerInstance$_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles $backgroundWorkerInstance$.RunWorkerCompleted
        ' This event fires when the DoWork event completes

    End Sub]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
