Sorry for the noobish question, my syntax is wrong and I cant understand why.
internal delegate void DoSomethingWithParam(MyObject localObjectToPassAsParam);
and I use it:
myControl.BeginInvoke(new FinishAddingEntitiesToFolderDelegate(FunctionNameWithSignatureAsDelegate), localObjectToPassAsParam);
This will call my function OK:
private void FunctionNameWithSignatureAsDelegate(MyObject localObjectToPassAsParam)
{
Logger.Debug(localObjectToPassAsParam);
}
This works fine, when I try doing so with anonymous delegate it does not compile.
Where Am I suppose to put the parameter ?
myControl.BeginInvoke((Action<MyObject >)(() =>
{
//I want to use my object here..
}));
Tried it this way?
myControl.BeginInvoke((localObjectToPassAsParam)=>
{
// Your code here
}));
Let localObjectToPassAsParam be the instance of your object ;-) Please try and let me know, whether it worked in terms of type safety.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.