|
@@ -5,6 +5,7 @@ using System.Timers;
|
|
using System.Threading;
|
|
using System.Threading;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
using System.Runtime.ExceptionServices;
|
|
using System.Runtime.ExceptionServices;
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
|
|
namespace BBIWARG.Input.InputProviding
|
|
namespace BBIWARG.Input.InputProviding
|
|
{
|
|
{
|
|
@@ -75,32 +76,44 @@ namespace BBIWARG.Input.InputProviding
|
|
[HandleProcessCorruptedStateExceptions]
|
|
[HandleProcessCorruptedStateExceptions]
|
|
public void start()
|
|
public void start()
|
|
{
|
|
{
|
|
|
|
+ startTimeWatch = Stopwatch.StartNew();
|
|
Console.WriteLine("starting new AppDomain (" + startId +")...");
|
|
Console.WriteLine("starting new AppDomain (" + startId +")...");
|
|
domain = System.AppDomain.CreateDomain("AppDomain-" + startId);
|
|
domain = System.AppDomain.CreateDomain("AppDomain-" + startId);
|
|
|
|
|
|
startId++;
|
|
startId++;
|
|
|
|
|
|
wrapper = (IntelCameraWrapper) domain.CreateInstanceAndUnwrap(typeof(IntelCameraWrapper).Assembly.GetName().ToString(), typeof(IntelCameraWrapper).FullName);
|
|
wrapper = (IntelCameraWrapper) domain.CreateInstanceAndUnwrap(typeof(IntelCameraWrapper).Assembly.GetName().ToString(), typeof(IntelCameraWrapper).FullName);
|
|
- wrapper.init(this);
|
|
|
|
|
|
|
|
- IsActive = true;
|
|
|
|
|
|
+ var startTask = Task.Run(() => wrapper.init(this));
|
|
|
|
|
|
- if (DeviceStartedEvent != null) {
|
|
|
|
- DeviceStartedEvent(this, new EventArgs());
|
|
|
|
- DeviceStartedEvent = null; //only notify once...
|
|
|
|
|
|
+ if (!startTask.Wait(TimeSpan.FromSeconds(4)))
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine("Timeout during init");
|
|
|
|
+ errorstate = true;
|
|
|
|
+ scheduledForRestart = false;
|
|
}
|
|
}
|
|
|
|
+ else {
|
|
|
|
+ IsActive = true;
|
|
|
|
|
|
- scheduledForRestart = false;
|
|
|
|
- startTimeWatch = Stopwatch.StartNew();
|
|
|
|
|
|
+ if (DeviceStartedEvent != null)
|
|
|
|
+ {
|
|
|
|
+ DeviceStartedEvent(this, new EventArgs());
|
|
|
|
+ DeviceStartedEvent = null; //only notify once...
|
|
|
|
+ }
|
|
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- wrapper.run();
|
|
|
|
- }
|
|
|
|
- catch (System.AccessViolationException)
|
|
|
|
- {
|
|
|
|
- Console.WriteLine("Camera caused corrupted process state.");
|
|
|
|
- errorstate = true;
|
|
|
|
|
|
+ scheduledForRestart = false;
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ wrapper.run();
|
|
|
|
+ }
|
|
|
|
+ catch (System.AccessViolationException)
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine("Camera caused corrupted process state.");
|
|
|
|
+ errorstate = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
checkExitErrorstate();
|
|
checkExitErrorstate();
|