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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...