1
0
mirror of synced 2024-09-16 16:46:09 +00: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
uses
System.Classes,
X2UtService.Intf;
type
TX2ServiceContextGUI = class(TInterfacedObject, IX2ServiceContext)
TX2ServiceContextGUI = class(TInterfacedObject, IX2ServiceContext, IX2InteractiveServiceContext)
protected
procedure StartService(AService: IX2Service); virtual;
public
@ -14,6 +16,10 @@ type
{ IX2ServiceContext }
function GetMode: TX2ServiceMode;
{ IX2InteractiveServiceContext }
procedure RunInteractive(AProc: TThreadProcedure);
end;
@ -55,4 +61,10 @@ begin
Application.Run;
end;
procedure TX2ServiceContextGUI.RunInteractive(AProc: TThreadProcedure);
begin
TThread.Queue(nil, AProc);
end;
end.

View File

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