Skip to content

Instantly share code, notes, and snippets.

@sween
Created January 7, 2010 15:47
Show Gist options
  • Select an option

  • Save sween/271312 to your computer and use it in GitHub Desktop.

Select an option

Save sween/271312 to your computer and use it in GitHub Desktop.
private void button4_Click(object sender, EventArgs e)
{
/// This starts the animated image while I do the thing we are going
/// to do.
pictureBox1.Image = SHPortalEnrollment.Properties.Resources.loading;
delegateInstance = new ExampleDelegate(GetResult);
String threadid = Thread.CurrentThread.ManagedThreadId.ToString();
delegateInstance.BeginInvoke(new AsyncCallback(FinishResult), null);
}
public string GetResult()
{
/// Lets go consume the service
/// This is the operation that will run off on its own thread.
SHPortalEnrollment.PORTAL.MedSeekWebService enrollme = new SHPortalEnrollment.PORTAL.MedSeekWebService();
String returnresponse = enrollme.SHEnrollToMedSeek(textBox1.Text, textBox2.Text);
return returnresponse;
}
public void FinishResult(IAsyncResult results)
{
/// Things are done cooking, lets change the image and pass the results off
/// to be dealth with.
pictureBox1.Image = SHPortalEnrollment.Properties.Resources.sh;
string waitresults = delegateInstance.EndInvoke(results);
ResultStep(waitresults);
}
private void ResultStep(string result)
{
if (this.InvokeRequired)
{
this.Invoke(new EventHandler(delegate
{
// Now we can put the result back into the GUI
toolStripStatusLabel3.Text = "Result: Process Completed." + result;
}));
}
else
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment