Abaksoft Posted March 7, 2015 Posted March 7, 2015 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) ? Thx. Quote
Administrators Farshad Mohajeri Posted March 7, 2015 Administrators Posted March 7, 2015 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. Quote
sokel Posted March 13, 2015 Posted March 13, 2015 Hi Farshad! Is it safe to declare a variable in mainmodule that I would be using to hold like a username during the session life? My understanding is that the variable will be unique for each session! Thanks Sokel Quote
Administrators Farshad Mohajeri Posted March 13, 2015 Administrators Posted March 13, 2015 Hi Farshad! Is it safe to declare a variable in mainmodule that I would be using to hold like a username during the session life? My understanding is that the variable will be unique for each session! Thanks Sokel Correct. Quote
Administrators Farshad Mohajeri Posted March 13, 2015 Administrators Posted March 13, 2015 Let me remind that you must declare a public member for TUniMainModule class. Quote
sokel Posted March 17, 2015 Posted March 17, 2015 You mean the variable should be declared public in the mainmodule? Quote
sokel Posted March 17, 2015 Posted March 17, 2015 And in the interface section of the mainmodule? Quote
Abaksoft Posted March 17, 2015 Author Posted March 17, 2015 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. Quote
docjones Posted March 27, 2015 Posted March 27, 2015 Another question related. Can i use declared constants in global unit ? . Or better declare constants in unimainmodule ? Quote
Abaksoft Posted March 30, 2015 Author Posted March 30, 2015 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). Regards... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.