コード例 #1
0
        private void _RunCode(bool useNewThread = true, bool compileWithoutProject = false)
        {
            if (_runSource.IsRunning() && !_runSource.AllowMultipleExecution)
            {
                MessageBox.Show("Un programme est déjà en cours d'exécution !", "Run", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (GetCode() == "")
            {
                MessageBox.Show("Aucune instruction sélectionnée !", "Run", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (_runSource.SourceFile != null)
            {
                var file = zFile.CreateFileInfo(_runSource.SourceFile);
                if ((file.Attributes & FileAttributes.ReadOnly) == 0)
                {
                    Save();
                }
            }

            RazResult();
            RazProgress();

            _stopButton.Enabled = true;
            _runSource.RunCode(GetCode(), useNewThread, compileWithoutProject);
            _menuRunInit.Checked = _runSource.CallInit;
        }
コード例 #2
0
 private void Test_RunSource(IRunSource runSource, string s)
 {
     try
     {
         runSource.RunCode(s);
     }
     catch (Exception ex)
     {
         WriteMessage(ex.ToString() + "\r\n");
     }
 }
コード例 #3
0
        //private void SetCallInit(bool callInit)
        //{
        //    _runSource.CallInit = callInit;
        //}

        //private bool GetAllowMultipleExecution()
        //{
        //    return _runSource.AllowMultipleExecution;
        //}

        //private void SetAllowMultipleRun(bool allowMultipleRun)
        //{
        //    _runSource.AllowMultipleExecution = allowMultipleRun;
        //}


        //private void _RunCode(bool runOnMainThread = false, bool runWithoutProject = false)
        private async Task _RunCode(bool runOnMainThread = false, bool runWithoutProject = false)
        {
            if (!runOnMainThread)
            {
                runOnMainThread = _menuRunOnMainThread.Checked;
            }
            if (!runWithoutProject)
            {
                runWithoutProject = _menuRunWithoutProject.Checked;
            }
            bool allowMultipleRun = _menuAllowMultipleRun.Checked;
            bool callInit         = _menuRunInit.Checked;

            //if (_runSource.IsRunning() && !_runSource.AllowMultipleExecution)
            if (_runSource.IsRunning() && !allowMultipleRun)
            {
                MessageBox.Show("Un programme est déjà en cours d'exécution !", "Run", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (GetCode() == "")
            {
                MessageBox.Show("Aucune instruction sélectionnée !", "Run", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (_runSource.SourceFile != null)
            {
                var file = zFile.CreateFileInfo(_runSource.SourceFile);
                if ((file.Attributes & FileAttributes.ReadOnly) == 0)
                {
                    Save();
                }
            }

            RazResult();
            RazProgress();

            //_trace.WriteLine("_RunCode {0} {1} {2} {3}", runOnMainThread, allowMultipleRun, runWithoutProject, forceCallInit);
            Trace.WriteLine(GetRunSourceStatusRunType(runOnMainThread, allowMultipleRun, runWithoutProject, callInit));

            _stopButton.Enabled = true;
            await _runSource.RunCode(GetCode(), runOnMainThread : runOnMainThread, compileWithoutProject : runWithoutProject, allowMultipleRun : allowMultipleRun, callInit : callInit);

            _menuRunInit.Checked = _runSource.CallInitRunOnce;
            UpdateRunSourceStatus();
        }
コード例 #4
0
ファイル: Test_AppDomain_08.cs プロジェクト: 24/source_04
        //private static bool _selectTreeViewResult = false;  // true si il faut sélectionner le résultat du TreeView

        static void Main()
        {
            Console.WriteLine("Test_AppDomain_08 : test runsource.dll");
            AppDomain domain = AppDomain.CreateDomain("New Domain");

            //Console.WriteLine("set initial lease time to 10 sec");
            //LifetimeServices.LeaseTime = TimeSpan.FromSeconds(10);  // This is the InitialLeaseTime property
            //Console.WriteLine();

            DateTime dt1 = DateTime.Now;

            //IRunSource rs = (IRunSource)domain.CreateInstanceFromAndUnwrap("runsource.dll", "pb.RunSource");
            //Console.WriteLine("{0:HH:mm:ss} create object pb.RunSource", dt1);

            Console.WriteLine("{0:HH:mm:ss} create object RemoteRunSource", dt1);
            Console.WriteLine();
            RemoteRunSource remoteRunSource = new RemoteRunSource();

            _runSource = remoteRunSource.GetRunSource();
            _runSource.SetRunSourceConfig(@"c:\pib\prog\tools\runsource\runsource32_config.xml");
            //_runSource.Trace.Writed += new WritedEvent(EventWrited);
            Trace.CurrentTrace.SetViewer(EventWrited);
            _runSource.DisableMessageChanged  += new DisableMessageChangedEvent(EventDisableMessageChanged);
            _runSource.GridResultSetDataTable += new SetDataTableEvent(EventGridResultSetDataTable);
            _runSource.GridResultSetDataSet   += new SetDataSetEvent(EventGridResultSetDataSet);
            //_runSource.TreeViewResultAdd += new TreeViewResultAddEvent(EventTreeViewResultAdd);
            //_runSource.TreeViewResultSelect += new TreeViewResultSelectEvent(EventTreeViewResultSelect);
            _runSource.ErrorResultSet += new SetDataTableEvent(EventErrorResultSet);
            _runSource.ProgressChange += new ProgressChangeEvent(EventProgressChange);
            _runSource.EndRunCode     += new EndRunEvent(EventEndRun);


            DateTime dt2;
            string   s = "RunSource.CurrentDomainRunSource.Trace.WriteLine(DateTime.Now.ToString());";

            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
            {
                Thread.Sleep(100);
            }

            //Console.WriteLine("wait 15 sec");
            //Thread.Sleep(15000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            //Console.WriteLine("wait 2 min");
            //Thread.Sleep(120000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            Console.WriteLine("wait 6 min");
            Thread.Sleep(360000);
            //Console.WriteLine("wait 10 min");
            //Thread.Sleep(600000);
            //Console.WriteLine("wait 15 min");
            //Thread.Sleep(900000);
            //Console.WriteLine("wait 30 min");
            //Thread.Sleep(1800000);
            //Console.WriteLine("wait 2h");
            //Thread.Sleep(7200000);
            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
            {
                Thread.Sleep(100);
            }


            //for (int i = 0; i < 500; i++)
            //{
            //    Thread.Sleep(1000);
            //    DateTime dt2 = DateTime.Now;
            //    Console.WriteLine("{0,6} {1:HH:mm:ss}-{2} test_03.GetMessage() : {3}", i + 1, dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());
            //}

            AppDomain.Unload(domain);
        }
コード例 #5
0
ファイル: Test_RunSourceForm.cs プロジェクト: labeuze/source
 private void Test_RunSource(IRunSource runSource, string s)
 {
     try
     {
         runSource.RunCode(s);
     }
     catch (Exception ex)
     {
         WriteMessage(ex.ToString() + "\r\n");
     }
 }
コード例 #6
0
ファイル: Test_AppDomain_08.cs プロジェクト: labeuze/source
        //private static bool _selectTreeViewResult = false;  // true si il faut sélectionner le résultat du TreeView

        static void Main()
        {
            Console.WriteLine("Test_AppDomain_08 : test runsource.dll");
            AppDomain domain = AppDomain.CreateDomain("New Domain");

            //Console.WriteLine("set initial lease time to 10 sec");
            //LifetimeServices.LeaseTime = TimeSpan.FromSeconds(10);  // This is the InitialLeaseTime property
            //Console.WriteLine();

            DateTime dt1 = DateTime.Now;
            //IRunSource rs = (IRunSource)domain.CreateInstanceFromAndUnwrap("runsource.dll", "pb.RunSource");
            //Console.WriteLine("{0:HH:mm:ss} create object pb.RunSource", dt1);

            Console.WriteLine("{0:HH:mm:ss} create object RemoteRunSource", dt1);
            Console.WriteLine();
            RemoteRunSource remoteRunSource = new RemoteRunSource();
            _runSource = remoteRunSource.GetRunSource();
            _runSource.SetRunSourceConfig(@"c:\pib\prog\tools\runsource\runsource32_config.xml");
            //_runSource.Trace.Writed += new WritedEvent(EventWrited);
            Trace.CurrentTrace.SetViewer(EventWrited);
            _runSource.DisableMessageChanged += new DisableMessageChangedEvent(EventDisableMessageChanged);
            _runSource.GridResultSetDataTable += new SetDataTableEvent(EventGridResultSetDataTable);
            _runSource.GridResultSetDataSet += new SetDataSetEvent(EventGridResultSetDataSet);
            //_runSource.TreeViewResultAdd += new TreeViewResultAddEvent(EventTreeViewResultAdd);
            //_runSource.TreeViewResultSelect += new TreeViewResultSelectEvent(EventTreeViewResultSelect);
            _runSource.ErrorResultSet += new SetDataTableEvent(EventErrorResultSet);
            _runSource.ProgressChange += new ProgressChangeEvent(EventProgressChange);
            _runSource.EndRunCode += new EndRunEvent(EventEndRun);


            DateTime dt2;
            string s = "RunSource.CurrentDomainRunSource.Trace.WriteLine(DateTime.Now.ToString());";

            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
                Thread.Sleep(100);

            //Console.WriteLine("wait 15 sec");
            //Thread.Sleep(15000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            //Console.WriteLine("wait 2 min");
            //Thread.Sleep(120000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            Console.WriteLine("wait 6 min");
            Thread.Sleep(360000);
            //Console.WriteLine("wait 10 min");
            //Thread.Sleep(600000);
            //Console.WriteLine("wait 15 min");
            //Thread.Sleep(900000);
            //Console.WriteLine("wait 30 min");
            //Thread.Sleep(1800000);
            //Console.WriteLine("wait 2h");
            //Thread.Sleep(7200000);
            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
                Thread.Sleep(100);


            //for (int i = 0; i < 500; i++)
            //{
            //    Thread.Sleep(1000);
            //    DateTime dt2 = DateTime.Now;
            //    Console.WriteLine("{0,6} {1:HH:mm:ss}-{2} test_03.GetMessage() : {3}", i + 1, dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());
            //}

            AppDomain.Unload(domain);
        }