J
Jon
Why are out parmeters included in an BeginInvoke? They seem to do
nothing?
TestProgam:
using System;
namespace TempConsole {
class App {
public delegate void MyDelegate( out byte b, out string s );
public static void OnMyDelegate( out byte b, out string s ) {
b = 10;
s = "Changed by Delegate.";
}
static void Main( string[] arg s) {
MyDelegate md = new MyDelegate( OnMyDelegate );
byte b1 = 1;
string s1 = "Unchanged by Delegate.";
IAsyncResult ar = md.BeginInvoke(out b1, out s1, null,
null);
ar.AsyncWaitHandle.WaitOne();
byte b2 = 2;
string s2 = "Will be changed by Delegate.";
md.EndInvoke(out b2, out s2, ar);
Console.WriteLine( "BeginInvoke out arguments: {0}, {1}",
b1, s1 );
Console.WriteLine( "EndInvoke out arguments: {0}, {1}",
b2, s2 );
Console.ReadLine();
}
}
}
Results:
BeginInvoke out arguments: 1, Unchanged by Delegate.
EndInvoke out arguments: 10, Changed by Delegate.
nothing?
TestProgam:
using System;
namespace TempConsole {
class App {
public delegate void MyDelegate( out byte b, out string s );
public static void OnMyDelegate( out byte b, out string s ) {
b = 10;
s = "Changed by Delegate.";
}
static void Main( string[] arg s) {
MyDelegate md = new MyDelegate( OnMyDelegate );
byte b1 = 1;
string s1 = "Unchanged by Delegate.";
IAsyncResult ar = md.BeginInvoke(out b1, out s1, null,
null);
ar.AsyncWaitHandle.WaitOne();
byte b2 = 2;
string s2 = "Will be changed by Delegate.";
md.EndInvoke(out b2, out s2, ar);
Console.WriteLine( "BeginInvoke out arguments: {0}, {1}",
b1, s1 );
Console.WriteLine( "EndInvoke out arguments: {0}, {1}",
b2, s2 );
Console.ReadLine();
}
}
}
Results:
BeginInvoke out arguments: 1, Unchanged by Delegate.
EndInvoke out arguments: 10, Changed by Delegate.