Inheritance: System.MarshalByRefObject, IEntry
示例#1
0
        public int StartCode(string Data, string MainConstructor, Abstract A, ref string ErrorMessage, ref int ErrorCode)
        {
            try
            {
                if (IsFor(Data) || IsDo(Data) || IsWhile(Data))
                {
                    bool b      = false;
                    var  thread = new Thread(() =>
                    {
                        try
                        {
                            A.GetType().InvokeMember(MainConstructor, BindingFlags.InvokeMethod | BindingFlags.Default, null, A, null);
                            b = true;
                        }
                        catch (Exception)
                        {
                            // None
                        }
                    });

                    thread.Start();
                    thread.Join(2);
                    thread.Abort();

                    if (!b)
                    {
                        return(0);
                    }
                }
                else
                {
                    A.GetType().InvokeMember(MainConstructor, BindingFlags.InvokeMethod | BindingFlags.Default, null, A, null);
                }
            }
            catch (Exception e)
            {
                ErrorCode    = 0;
                ErrorMessage = e.Message;
                return(-1);
            }

            return(1);
        }
示例#2
0
        public int StartCode(string Data, string MainConstructor, Abstract A, ref string ErrorMessage, ref int ErrorCode)
        {
            try
            {
                if(IsFor(Data) || IsDo(Data) || IsWhile(Data))
                {
                    bool b = false;
                    var thread = new Thread(() =>
                    {
                        try
                        {
                            A.GetType().InvokeMember(MainConstructor, BindingFlags.InvokeMethod | BindingFlags.Default, null, A, null);
                            b = true;
                        }
                        catch(Exception)
                        {
                            // None
                        }
                    });

                    thread.Start();
                    thread.Join(100);
                    thread.Abort();

                    if(!b)
                        return 0;
                }
                else
                    A.GetType().InvokeMember(MainConstructor, BindingFlags.InvokeMethod | BindingFlags.Default, null, A, null);
            }
            catch(Exception e)
            {
                ErrorCode = 0;
                ErrorMessage = e.Message;
                return -1;
            }

            return 1;
        }