Last change
on this file since 16985 was
16984,
checked in by dpiringe, 5 years ago
|
#2924:
- merged projects HeuristicLab.PluginInfrastructure.Runner and HeuristicLab.PluginInfrastructure
- applied changes of code reviews (13.05.2019 and 22.05.2019) -> the old Runner is now RunnerHost and uses a Runner, which is executed on the child process
- added Type GetType(string) to IApplicationManager and implemented it for LightweightApplicationManager
- removed IActivator and IActivatorContext
- deleted unused types like PluginDescriptionIterator
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.IO;
|
---|
4 | using System.Text;
|
---|
5 |
|
---|
6 | namespace HeuristicLab.PluginInfrastructure {
|
---|
7 | [Serializable]
|
---|
8 | public class ApplicationRunner : Runner {
|
---|
9 | /// <summary>
|
---|
10 | /// Arguments for the StartApplication.
|
---|
11 | /// </summary>
|
---|
12 | public ICommandLineArgument[] Args { get; set; }
|
---|
13 |
|
---|
14 | /// <summary>
|
---|
15 | /// The application which should run in child process.
|
---|
16 | /// </summary>
|
---|
17 | public IApplication StartApplication {
|
---|
18 | get {
|
---|
19 | using (var memStream = new MemoryStream(serializedStartApplication)) {
|
---|
20 | return (IApplication)formatter.Deserialize(memStream);
|
---|
21 | }
|
---|
22 | }
|
---|
23 | set {
|
---|
24 | using (var ms = new MemoryStream()) {
|
---|
25 | formatter.Serialize(ms, value);
|
---|
26 | serializedStartApplication = ms.ToArray();
|
---|
27 | }
|
---|
28 | }
|
---|
29 | }
|
---|
30 | // Encapsulated application is necessary, because it is not possible to
|
---|
31 | // instantly deserialize the application, before all assemblies are loaded.
|
---|
32 | private byte[] serializedStartApplication = new byte[0];
|
---|
33 |
|
---|
34 | protected override void Execute() {
|
---|
35 | StartApplication.Run(Args);
|
---|
36 | }
|
---|
37 |
|
---|
38 | protected override void OnRunnerJob(RunnerJob runnerJob) {
|
---|
39 | switch (runnerJob) {
|
---|
40 | case RunnerJob.Cancel: StartApplication.OnCancel(); break;
|
---|
41 | case RunnerJob.Pause: StartApplication.OnPause (); break;
|
---|
42 | case RunnerJob.Resume: StartApplication.OnResume(); break;
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|
46 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.