Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/26/14 16:38:08 (11 years ago)
Author:
abeham
Message:

#2136: merged r10359, r10391, r10401, r10506 to stable

Location:
stable
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.HLScript/3.3

    • Property svn:global-ignores set to
      bin
      obj
      Plugin.cs
  • stable/HeuristicLab.HLScript/3.3/Script.cs

    r10401 r10891  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.CodeDom;
    324using System.CodeDom.Compiler;
     
    1637using Microsoft.CSharp;
    1738
    18 namespace HeuristicLab.HLScript {
    19   [Item("Script", "A HeuristicLab script.")]
     39namespace HeuristicLab.Scripting {
     40  [Item("Script", "An empty C# script.")]
    2041  [Creatable("Scripts")]
    2142  [StorableClass]
     
    2748
    2849using System;
    29 
    30 namespace UserScripts {
    31   public class UserScript : HeuristicLab.HLScript.UserScriptBase {
    32     public override void Main() {
    33       // type your code here
    34     }
    35 
    36     // further classes and methods
    37 
     50using System.Linq;
     51using System.Collections.Generic;
     52using HeuristicLab.Common;
     53using HeuristicLab.Core;
     54using HeuristicLab.Data;
     55
     56public class UserScript : HeuristicLab.Scripting.UserScriptBase {
     57  public override void Main() {
     58    // type your code here
    3859  }
     60
     61  // further classes and methods
     62
    3963}";
    4064    #endregion
     
    126150        GenerateExecutable = false,
    127151        GenerateInMemory = true,
    128         IncludeDebugInformation = false
     152        IncludeDebugInformation = true,
     153        WarningLevel = 4
    129154      };
    130155      parameters.ReferencedAssemblies.AddRange(
     
    212237      if (executeMethod != null) {
    213238        scriptThread = new Thread(() => {
     239          Exception ex = null;
    214240          try {
    215241            OnScriptExecutionStarted();
    216242            executeMethod.Invoke(compiledScript, new[] { VariableStore });
     243          } catch (ThreadAbortException) {
     244            // the execution was cancelled by the user
     245          } catch (TargetInvocationException e) {
     246            ex = e.InnerException;
    217247          } finally {
    218             OnScriptExecutionFinished();
     248            OnScriptExecutionFinished(ex);
    219249          }
    220250        });
     
    250280    }
    251281
    252     public event EventHandler ScriptExecutionFinished;
    253     private void OnScriptExecutionFinished() {
     282    public event EventHandler<EventArgs<Exception>> ScriptExecutionFinished;
     283    private void OnScriptExecutionFinished(Exception e) {
    254284      var handler = ScriptExecutionFinished;
    255       if (handler != null) handler(this, EventArgs.Empty);
     285      if (handler != null) handler(this, new EventArgs<Exception>(e));
    256286    }
    257287
Note: See TracChangeset for help on using the changeset viewer.