Jump to content

is a standard Delphi Unit thead safe ?


Recommended Posts

Hi all,

I want to use an UniFrame with controls, and write its business logic on a seaparate unit (add a standard Delphi Unit) let's say Ucode.pas


This technic allows to write code ones (same base code) for desktop and mobile (just add an other UniFrame for mobile and use the same Unit Ucode.pas)


1- Is it a good way ?

2- In other word is a standard Unit thread safe ?

3- Can i use instead an UniDataModule ?

4- Is it a plane to integate an UniUnit (thread safe) ?


Link to comment
Share on other sites

  • Administrators

You can use a DataModule created from uniGUI wizard.


Write your business logic in this DataModule and share it among mobile and desktop.


As long as you don't use global variables your code is thread-safe provided that you don't use any third-party component which is not thread-safe.

Link to comment
Share on other sites

Hi sokel,

yes :

- MainModule and UniDataModule are Client side (Target each cession).

- ServerModule is Server side. It's dangerous and forbidden to declare a public variable on serverModule.


In public section of MainModule, your variable will be global for one thread (1 cession). That's the correct way.

Link to comment
Share on other sites

In my knowledge : Yes the two are possible.

1. If you declare it in a global unit (standard Delphi Unit) the constant is the same for all clients (sessions).


2. If you declare it in an UniDataModule or MainModule your constant will be viewed only by one client (its session).



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.

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...