Jump to content

UniSession.Synchronize() inside a dll


lcolombo

Recommended Posts

195/5000
 
 
 
Hi,
My application needs to show and update a form contained in a dll. The application calls two functions of the dll, one to create and display the form and another to display a text.
The application works well with a single user, but when there are two users using it at the same time I get unexpected errors. For example, the progress of the first user is interrupted when the progress of the second user begins.
 
The same code without the dll, works correctly, but I need to implement it with the dll.
 
any ideas ?
 
Application code:

unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniGUIBaseClasses, uniButton;

type
  TMainForm = class(TUniForm)
    UniButton1: TUniButton;
    procedure UniButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function MainForm: TMainForm;

implementation

{$R *.dfm}

uses
  uniGUIVars, MainModule, uniGUIApplication;

procedure DOSTART () ; stdcall; pascal; external 'F32IO.dll';
procedure DOPREVIEW (Text: PChar); stdcall; pascal; external 'F32IO.dll';

function MainForm: TMainForm;
begin
  Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end;

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  i,j : integer;
  str : string;
begin
    DoStart();
    for I := 0 to 20 do
    begin
         str := inttostr(i) + ' - ID:' + Unisession.SessionId;
         DoPreview(PCHAR(str));
    end;
end;

initialization
  RegisterAppFormClass(TMainForm);

end.

 

DLL Code:

library F32IO;

uses
  System.SysUtils,
  System.Classes,
  VCL.Dialogs,
  uniGUIApplication,
  F32Console in 'F32Console.pas' {FlorConsoleForm: TUniForm},
  uniGUIForm {FlorConsoleForm: TUniForm};


{$R *.res}


function DoPreview(Text: PChar): Longint; pascal;
var
  pstr : string;
begin
    pstr := string(Text);
    FlorConsoleForm.Console.Items.Add(pstr);
    UniSession.Synchronize();
end;


function DoStart(): Longint; pascal;
begin
   FlorConsoleForm := TFlorConsoleForm.Create(UniApplication);
   FlorConsoleForm.Show;
   FlorConsoleForm.Console.Items.Add('DoStart');
   FlorConsoleForm.Console.Items.Add(UniSession.SessionId);
   Result:= 0;
end;


exports

  DoPreview           index  1 name 'DOPREVIEW',
  DoStart             index  2 name 'DOSTART';

begin
end.

 

Regards

 

Link to comment
Share on other sites

  • 2 weeks later...

I changed this: 

var
   FlorConsoleForm: TFlorConsoleForm;

 

for that:

 

   function FlorConsoleForm: TFlorConsoleForm;

implementation

uses
  uniGUIApplication;

function FlorConsoleForm: TFlorConsoleForm;
begin
  Result := TFlorConsoleForm(UniApplication.UniMainModule.GetFormInstance(TFlorConsoleForm));
end;

 

Regards,

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...