1
0
mirror of synced 2024-12-22 17:23:07 +01:00

Added IX2InteractiveServiceContext interface to allow running code in the main thread when in an interactive context

This commit is contained in:
Mark van Renswoude 2016-12-14 11:20:45 +01:00
parent 8de40e4f85
commit 72d08518f8
2 changed files with 21 additions and 2 deletions

View File

@ -2,11 +2,13 @@ unit X2UtService.GUIContext;
interface interface
uses uses
System.Classes,
X2UtService.Intf; X2UtService.Intf;
type type
TX2ServiceContextGUI = class(TInterfacedObject, IX2ServiceContext) TX2ServiceContextGUI = class(TInterfacedObject, IX2ServiceContext, IX2InteractiveServiceContext)
protected protected
procedure StartService(AService: IX2Service); virtual; procedure StartService(AService: IX2Service); virtual;
public public
@ -14,6 +16,10 @@ type
{ IX2ServiceContext } { IX2ServiceContext }
function GetMode: TX2ServiceMode; function GetMode: TX2ServiceMode;
{ IX2InteractiveServiceContext }
procedure RunInteractive(AProc: TThreadProcedure);
end; end;
@ -55,4 +61,10 @@ begin
Application.Run; Application.Run;
end; end;
procedure TX2ServiceContextGUI.RunInteractive(AProc: TThreadProcedure);
begin
TThread.Queue(nil, AProc);
end;
end. end.

View File

@ -2,7 +2,8 @@ unit X2UtService.Intf;
interface interface
uses uses
Classes; System.Classes,
System.SysUtils;
type type
@ -17,6 +18,12 @@ type
end; end;
IX2InteractiveServiceContext = interface(IX2ServiceContext)
['{82E69997-013D-4349-8060-B9F31B72CDF4}']
procedure RunInteractive(AProc: TThreadProcedure);
end;
IX2Service = interface IX2Service = interface
['{C8597906-87B8-444E-847B-37A034F72FFC}'] ['{C8597906-87B8-444E-847B-37A034F72FFC}']
function GetServiceName: string; function GetServiceName: string;