Torna al Thread
/// <summary>Dispatches an asynchronous message to a synchronization context.</summary>
/// <param name="d">The <see cref="T:System.Threading.SendOrPostCallback" /> delegate to call.</param>
/// <param name="state">The object passed to the delegate.</param>
public override void Post(SendOrPostCallback d, object state)
{
if (this.controlToSendTo != null)
{
Control control = this.controlToSendTo;
object[] objArray = new object[] { state };
control.BeginInvoke(d, objArray);
}
}
/// <summary>Dispatches a synchronous message to a synchronization context</summary>
/// <param name="d">The <see cref="T:System.Threading.SendOrPostCallback" /> delegate to call.</param>
/// <param name="state">The object passed to the delegate.</param>
/// <exception cref="T:System.ComponentModel.InvalidAsynchronousStateException">The destination thread no longer exists.</exception>
public override void Send(SendOrPostCallback d, object state)
{
Thread destinationThread = this.DestinationThread;
if (destinationThread == null || !destinationThread.IsAlive)
{
throw new InvalidAsynchronousStateException(SR.GetString("ThreadNoLongerValid"));
}
if (this.controlToSendTo != null)
{
Control control = this.controlToSendTo;
object[] objArray = new object[] { state };
control.Invoke(d, objArray);
}
}