Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save evonsdesigns/9521811 to your computer and use it in GitHub Desktop.
Save evonsdesigns/9521811 to your computer and use it in GitHub Desktop.
Threadsafe calls for C# WinForms, with zero parameters in method
// Create the callback method
delegate Boolean checkIfMoveToUploadedFolderCallback();
// define the method to be called
private Boolean checkIfMoveToUploadedFolder()
{
// check control property InvokeRequired
if (cb_moveToUploadedFolder.InvokeRequired)
{
// create an instance of the delegate with this method's name
checkIfMoveToUploadedFolderCallback s = new checkIfMoveToUploadedFolderCallback(checkIfMoveToUploadedFolder);
// return a casted invocation of the callback
return (Boolean)this.Invoke(s);
}
else
{
// perform the access on the control's object as expected
return cb_moveToUploadedFolder.Checked;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment