vendredi 13 avril 2018

Terminate Reflection Invoke Method

I am doing dynamic code compilation using roslyn compiler.The compiled assembly executed by using reflection Invoke method.

Type type = Assembly.GetType("Namespace.Program");
MethodInfo methodInfo = type.GetMethod("Main");
methodInfo.Invoke(null, new object[] { args });

Here i am facing issue, if the compiled code have, Example

public class Program
{
    static void Main(string[] args)
    {
      Console.ReadLine();
    }
}

Console.ReadLine(); blocks program execution and leads to memory leaks/server down, for blocking reason i would like to terminate invoke function after some time.I was wondering if anyone can help me on terminate Invoke funtion or any other way to do





Aucun commentaire:

Enregistrer un commentaire