78 lines
2.8 KiB
C#
78 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Runtime.InteropServices;
|
|
using System.Reflection;
|
|
|
|
// Ooganizer Namespaces
|
|
using Foo.Platform;
|
|
using Foo.DataAccessLayer;
|
|
using Foo.DataAccessLayer.DataTypes;
|
|
|
|
namespace Foo.ClientServices.GUIWPForms
|
|
{
|
|
/// <summary>
|
|
/// This class is responsible for launch all secondary threads required for this application as
|
|
/// well as hold any variables that are needed by all classes
|
|
/// created.
|
|
/// </summary>
|
|
[ComVisible(false)]
|
|
internal class ComponentState
|
|
{
|
|
// Declare the Log4net Variable
|
|
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
/// <summary>
|
|
/// This class manages the state / main variables of the COM+ that maybe needed by multiple classes.
|
|
/// It is responsible for starting and stopping any secondary threads.
|
|
/// </summary>
|
|
static ComponentState()
|
|
{
|
|
// We must subscribe to assembly resolver
|
|
Log.Info(string.Format("{0}() - GUIWPForms ComponentState() called. Application is starting...", MethodBase.GetCurrentMethod().Name));
|
|
|
|
// Let's Preload the Database *Right here, right now* that should be good for all of us
|
|
Data.Artifacts.DoesArtifactExistInSystem(DataTypeHelpers.CreateLocationOnlyArtifact("C:\\Dummy.file"));
|
|
|
|
// Start GUI Dispatcher Thread
|
|
Log.Info(string.Format("{0}() - GUIWPForms ComponentState() called. Activating DispatcherThread", MethodBase.GetCurrentMethod().Name));
|
|
DispatcherThread.Run = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Private Variables
|
|
/// </summary>
|
|
private static bool s_bApplicationIsRunning = false;
|
|
|
|
/// <summary>
|
|
/// Use this to enable/disable all threads and variables for
|
|
/// the component states
|
|
/// </summary>
|
|
public static bool ApplicationIsRunning
|
|
{
|
|
get { return s_bApplicationIsRunning; }
|
|
set
|
|
{
|
|
if (!value)
|
|
{
|
|
Log.Info(string.Format("{0}() - ComponentState() sApplicationRunning set to False", MethodBase.GetCurrentMethod().Name));
|
|
DispatcherThread.Run = false;
|
|
}
|
|
|
|
s_bApplicationIsRunning = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use this to access the GUIFormsMgr Object in order to
|
|
/// communicate to wpfForms (Setter should only be called by
|
|
/// DispatcherThread)
|
|
/// </summary>
|
|
public static GUIFormsMgr GUIFormsMgr
|
|
{
|
|
get { return DispatcherThread.s_GUIFormsMgr; }
|
|
}
|
|
}
|
|
}
|