.NETGURU
Can a WinForm be a remoted object?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.remoting.

Post a new message to this list...

Julia
Hi,

I have a server application which composed from a form which uses the Task
pattern to run background processes(threads),
each process is correctly update the user interface in the UI thread.

I want to allow ASP.NET application to call a method on my server
Since it is my first attempt I would like not to deal with synchronization
issue

1.is it possible to make the form a Server activated remoted object?
2.Will the call made in the UI thread?

Thanks in advance.

Reply to this message...
 
    
Ken Kolda
See comments inline below...

"Julia" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Yes, but perhaps not advisable. Since a Form derives MarshalByRefObject, it
can be remoted and used by a client app. If you decide to do this, what you
would need to do is marshal your form instance manually. For example, in
your form's contructor you might call:

RemotingServices.Marshal(this, "ServerForm.rem", typeof(IServerForm));

Almost certainly you don't want to compile your server form into the client
app, so you should have your form implement an interface (e.g. IServerForm)
that exposes the methods you need. Once you've done this, the clients can
use Activator.GetObject() to fetch your server form.

> 2.Will the call made in the UI thread?

Remoting calls will never be made in the UI thread, so you will always need
to marshal them using Form.Invoke() (or BeginInvoke()). This is another
reason why it's good to have a interfaces specifically for remoting. That
way you can limit the methods the client has access to so you only need to
worry about calling Invoke() in those.

I would recommend though that you not remote your actual form instance.
Instead, create another class that implements IServerForm and forwards the
calls to the main form. This would be especially important if this form may
be disposed during the lifetime of your app. That said, if your server form
will live for the entire lifetime of your server app, then it should be fine
(just remember to override InitializeLifetimeServices()).

Ken

Reply to this message...
 
 
System.Activator
System.MarshalByRefObject
System.Runtime.Remoting.RemotingServices
System.Windows.Forms.Form




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification