Abaksoft Posted March 7, 2015 Share 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. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 7, 2015 Administrators Share 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. Link to comment Share on other sites More sharing options...
Abaksoft Posted March 7, 2015 Author Share Posted March 7, 2015 Thx Farshad... Link to comment Share on other sites More sharing options...
sokel Posted March 13, 2015 Share 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 Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 13, 2015 Administrators Share 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. Link to comment Share on other sites More sharing options...
sokel Posted March 13, 2015 Share Posted March 13, 2015 Thank you sir Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 13, 2015 Administrators Share Posted March 13, 2015 Let me remind that you must declare a public member for TUniMainModule class. Link to comment Share on other sites More sharing options...
sokel Posted March 17, 2015 Share Posted March 17, 2015 You mean the variable should be declared public in the mainmodule? Link to comment Share on other sites More sharing options...
sokel Posted March 17, 2015 Share Posted March 17, 2015 And in the interface section of the mainmodule? Link to comment Share on other sites More sharing options...
Abaksoft Posted March 17, 2015 Author Share 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. Link to comment Share on other sites More sharing options...
sokel Posted March 24, 2015 Share Posted March 24, 2015 Thank you sir Link to comment Share on other sites More sharing options...
docjones Posted March 27, 2015 Share Posted March 27, 2015 Another question related. Can i use declared constants in global unit ? . Or better declare constants in unimainmodule ? Link to comment Share on other sites More sharing options...
Abaksoft Posted March 30, 2015 Author Share 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... Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now