How to stop executing method on server??

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: and81 (andrucha_at_o2.pl)
Date: 03/07/05


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)
  {...}
}



Relevant Pages

  • Re: screen scrape / remote manipulation
    ... Functionally a dll is no different from an .exe in terms of spying ... The other option is to install software capable of monitoring TCP/IP port ... connection is established between the dll (on the client) and the server, ...
    (microsoft.public.windowsxp.general)
  • Each client gets the same port number
    ... This class creates a server socket that will ... For each new connection request from client ... */ private String calculate{String result = null; ...
    (comp.lang.java.help)
  • Re: pygame and socket.recv
    ... player, and for the communication, I am sending a pickle string across ... The client sends a dictionary to the server. ... time.sleep to keep the frame rate at 40 frames per second. ...
    (comp.lang.python)
  • RE: SoapHttpClientProtocol request canceled
    ... Since this is only happening on the VB client, is there any chance that the ... The VB.NET exe and the VB6 exe both use VB.NET dll to sent request/response ... > inputHeaderer, String messageControlPayload, string inputMessage) ... > Imports System.ComponentModel ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Applet Consideration
    ... > the client applet to connect to the server. ... everything is sent as String. ... >> I made it so the client has absolutely no knowledge that the db exists. ... Each thread must be initialized by a login. ...
    (comp.lang.java.databases)