How to stop executing method on server??
From: and81 (andrucha_at_o2.pl)
Date: 03/07/05
- Next message: Sean Hederman: "Re: Is there any helpful material available to write an Unmanaged Remoting Client?"
- Previous message: Zuurstof via .NET 247: "Question about remoting using channels"
- Messages sorted by: [ date ] [ thread ]
Date: 7 Mar 2005 13:12:56 -0800
Hi!
I try to write application in C# using Remoting and I came to a
standstill, so please HELP ME!! :)
This is an idea:
1. Client send to server a file (dll) with some classes and methods in
it
2. Server write this file to direcotry (random name) and return to
client name of this directory
3. Client send to serwer file path, class name, method name and
arguments in order to invoke certain method from dll
4. Server invokes method and returns result to client
5. Client, after getting result from server, call delete method, which
deletes dll from server
I run invoking method (3. and 4.) in separately thread on client's
behalf, because I assume that executing method from dll will take
plenty of time. Problem appears when client abort this thread - server
is still running and I don't know how to stop it.
So far I used SingleCall model, but I think that in this way it's
immposible to solve this problem. I try to use Singleton and run
separate thread on server's behalf, but it works only for void methods
- I can't return a value from thread. I know, that I can create an
object and in thread save in it return value, but how and when I should
return this object to the client? I think about events (I'm reading
about this in Ingo Rammer's book), but maybe there is a better way to
break executing method on server?
Can someone tell me what is the best way to solve this problem?
Some server's code:
public String RegisterFile(byte[] file, string fileName)
{
String dirName = null;
do
{
dirName = RandomName();
}
while(Directory.Exists(dirName));
Directory.CreateDirectory(dirName);
String filePath = dirName + @"\" + fileName;
SaveFile(file, filePath);
ServerService.evt.WriteEntry(@"Zarejestrowano plik: \" + filePath);
return = filePath;
}
public object CallMethod(string filePath, string className, string
methodName, object[] args)
{
object result = new object();
try
{
byte[] fileContent = FileToBytes(filePath);
Assembly assembly = Assembly.Load(fileContent);
Type typ = assembly.GetType(className);
if(typ == null)
{
throw new Exception("Exception... bla bla");
}
object obj = Activator.CreateInstance(typ);
return typ.InvokeMember(methodName, flags |
BindingFlags.InvokeMethod, null, obj, args); // This take a very long
time
}
catch(Exception E)
{...}
}
- Next message: Sean Hederman: "Re: Is there any helpful material available to write an Unmanaged Remoting Client?"
- Previous message: Zuurstof via .NET 247: "Question about remoting using channels"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|