DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 22 Aug 2007 09:47:07 -0500,    posted on: microsoft.public.dotnet.framework.windowsforms        back       

Thread Index
  1    Lee Crabtree


Control.Invoke and anonymous methods   
I'm a little confused about using Control.Invoke with an anonymous 
method.  It seems like the compiler is able to generate whatever glue 
code is necessary to turn an anonymous method into a delegate type in 
several situations, such as starting a thread:

Thread workerThread = new Thread(delegate { MessageBox.Show("Hello!"); });

However, trying to do the same thing with a form, as in:

Form1.Invoke(delegate { MessageBox.Show("Hello!"); });

nets an error stating that an anonymous method is not a delegate type, 
and can't be converted.  It's easy enough to wrap the anonymous method 
in a MethodInvoker or whatever other required delegate type, but I don't 
really understand why the difference exists at all.

Lee Crabtree
Date:Wed, 22 Aug 2007 09:47:07 -0500   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us