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 06:34:03 -0700,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    Mike Logan am
          2    UL-Tomten
          3    (Steven Cheng[MSFT])


Starting a function on another thread   
My environment:  VS 2k5 Team Software developer SP1, VB.Net, Web Service

I have a web service.  I also have another class file.  I am trying to call 
a web service operation from within my private class file on another thread.

In my class file I have this

Private Sub MyPrivateSub()

  Dim serv1 as MyWebServiceClass

  Dim t1 as New System.Threading.Thread( _
      New System.Threading.ThreadStart( _
          AddressOf serv1.Operation1))

End Sub

I can't get past that line to create the thread.  The error is

Method 'Public Function Operation1(byval Param1 as Object) as ReturnObject' 
doesn't have the same signature as delegate 'Delegate Sub ThreadStart()'

The web serivce class has a parameter-less constructor.

Thanks for any help.

-- 
Mike Logan
Date:Wed, 22 Aug 2007 06:34:03 -0700   Author:  

Re: Starting a function on another thread   
On Aug 22, 3:34 pm, Mike Logan <MikeLo...@community.nospam> wrote:


> Method 'Public Function Operation1(byval Param1 as Object) as ReturnObject'
> doesn't have the same signature as delegate 'Delegate Sub ThreadStart()'


The error message isn't kidding. The signatures really are different.
Just look:

Sub ThreadStart()
vs
Function Operation1(byval Param1 as Object) as ReturnObject

You have to match the signature to be able to use the method as a
ThreadStart. The reason you can't return anything in the method is
that there's no control over the receiving end, so the returned object
would wind up nowhere.

If you can live with using the managed thread pool, you can use
delegates instead, which will give you easier access to function-like
behavior. Otherwise, the other delegate usable in Thread.Start() might
be of interest (but that one doesn't return anything either).
Date:Wed, 22 Aug 2007 07:50:28 -0700   Author:  

Re: Starting a function on another thread   
Hi Mike,

Does Tomten's suggestion help you on this problem? For creating custom 
thread which take a ThreadStart function, you need to define a function 
with the required signature of "ThreadStart delegate"(it is a void 
function):

#ThreadStart Delegate
http://msdn2.microsoft.com/en-us/library/system.threading.threadstart.aspx

or if you want your thread function be able to accept some additional 
parameters, you can choose the new "ParameterizedThreadStart delegate":

#ParameterizedThreadStart Delegate
http://msdn2.microsoft.com/en-us/library/system.threading.parameterizedthrea
dstart.aspx

BTW, for webservice client proxy, you can also use  
proxy.BeginXXXX/proxy.EndXXX methods   or the new proxy.XXXXAsync pattern 
to do asynchronous webservice call, these calles are also executed on 
another threadpool thread. 

#New Event-Based Model For Asynchronous WebMethod Calls
http://quickstarts.asp.net/QuickStartv20/webservices/doc/RADAsync.aspx

Does this also help for your case?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

 

==================================================

Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

 

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
 	

This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 23 Aug 2007 05:56:41 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


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