﻿<?xml version="1.0" encoding="UTF-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Use BeginInvoke on a Control to Run Code Asynchronously</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Uses BeginInvoke on a control to run code asynchronously.</Description>
      <Shortcut>osInvoke</Shortcut>
    </Header>
    <Snippet>
      <Platform>
        <Runtime>v2.0.40520</Runtime>
      </Platform>
      <Imports>
        <Import>
          <Namespace>Microsoft.VisualBasic</Namespace>
        </Import>
        <Import>
          <Namespace>System.Windows.Forms</Namespace>
        </Import>
        <Import>
          <Namespace>System</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Object>
          <ID>text1</ID>
          <Type>Control</Type>
          <ToolTip>Replace with the control instance.</ToolTip>
          <Default>TextBox1</Default>
          <Function />
        </Object>
        <Literal>
          <ID>str</ID>
          <Type />
          <ToolTip>Replace with String.</ToolTip>
          <Default>"Invoked"</Default>
          <Function />
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method decl"><![CDATA[Delegate Sub InvokeDelegate()

Public Sub Begin_Invoke()
    $text1$.BeginInvoke(New InvokeDelegate(AddressOf InvokeMethod))
End Sub

Public Sub InvokeMethod()
    $text1$.Text = $str$
End Sub]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>