Notice
The forum is in read only mode.
TOPIC: Execute vs ExecuteAsync in TRESTRequest
Execute vs ExecuteAsync in TRESTRequest 7 years 1 month ago #1490
Hi !
I am struggling with an issue where I am calling the RESTRequest1->ExecuteAsync() function. The problem is, it crashes my application. If I call RESTRequest1->Execute() it runs fine, but of course, my application lags. Is there anything special I should be aware of using ExecuteAsync() than Execute() ? --- Have tested it from AM 1.16 compilation for Samsung S4 Active w/Lillipop 5.0.1, also compiled for Windows 7 SP1. It crashes both on Android and Windows. Will test it from AM 1.15 soon. --- AM 1.16: Further testing shows that it can go well through one time, but the second time ExecutAsync() is called it crashes. --- AM 1.15: The error exists here as well... --- |
|
Execute vs ExecuteAsync in TRESTRequest 7 years 1 month ago #1531
I haven't used ExecuteAsync() myself a lot. An alternative option you have is to "manually" wrap the REST call in a TThread or a TTask, the latter being better (see documentation on Parallel Threading library). This works across platforms, and you can have in the thread also the data processing not blocking the UI. If there is code touching the UI, though, this should be out of the thread/task or need to be executed in Synchronize or Queue call.
|
|
Execute vs ExecuteAsync in TRESTRequest 7 years 1 month ago #1543
To add to what Marco said, you might want to look at this BaaS demo.
www.youtube.com/watch?v=RU0U-xKcshc cc.embarcadero.com/item/30117 Regards, Sarina |
|
Execute vs ExecuteAsync in TRESTRequest 7 years 1 month ago #1547
Hi again, thanx for the replies both of you!
Yes, I will try to use TThread or TTask, my intention was that in the beginning, but then I 'discovered' the ExecuteAsync() method when AM 1.16 was released (at least there was an explanation in the help pages here, instead of the frase 'Embarcadero Technologies does not currently have any additional information', which is for me very annoying... for the older versions of AM). Do you know anyone else which have used ExecuteAsync() (in C++) and can give us a good tutorial / best practice methods how to be sure we use the right precautions designing our applications using ExecuteAsync() ? It seems, for me at least, that there is some simpler approach for parallel programming with Delphi than C++, since you can have 'functions inside functions', am I right ? --- update --- By the way, are the TREST* functions threadsafe when they are 'connected' to UI's like TStringGrid via TFDMemTable (via TRESTResponseDataSetAdapter) ? So when ExecuteAsync is called, you will actually update the TStringGrid in the 'wrong' thread ? RG |
|
Execute vs ExecuteAsync in TRESTRequest 7 years 1 month ago #1563
Anyhow, I tried to make a demo app which just do GET requests in different ways using the TRESTRequest class. The demo is quite simple, it has all the TREST* classes, a TFDMemTable, a TStringGrid, 4 TButton components, and a TScrollBar which indicates a running function. It is setup as any other RESTful app, in my example i used the API from ' www.tileblock.com/scoreboard/list_users.php ' which do not require any crededentials or arguments. It dumps a JSON like this: {"tileblockusers":[{"uid":"1","username":"Roar","country":"Norway"},{"uid":"2","username":"Plg","country":"Norway"},{"uid":"3","username":"Petrn","country":"Norway "},{"uid":"4","username":"Llina","country":"Norway"},{"uid":"5","username":"Aalm","country":"Norway "},{"uid":"6","username":"Larsel","country":"Norway"},{"uid":"7","username":"Sigridlg","country":"Norway"},{"uid":"8","username":"genius","country":"Norway"},{"uid":"11","username":"genius2","country":"Norway"},{"uid":"12","username":"Mmann","country":"Deutschland"},{"uid":"14","username":"Mmann1","country":"Sweden"},{"uid":"15","username":"Norlin","country":"Norway "},{"uid":"16","username":"","country":""},{"uid":"17","username":"Roar2","country":"Norway "},{"uid":"18","username":"Roar3","country":"Norway"},{"uid":"20","username":"Roar4","country":"Norway"},{"uid":"22","username":"0","country":"Norway"},{"uid":"23","username":"4","country":"Norway"},{"uid":"25","username":"1","country":"Norway"},{"uid":"26","username":"Roar41","country":"Norway"},{"uid":"27","username":"Roar42","country":"Norway"},{"uid":"28","username":"Roar43","country":"Norway"},{"uid":"29","username":"Roar7","country":"Norway"},{"uid":"30","username":"Roar8","country":"Norway"},{"uid":"31","username":"Roar9","country":"Norway"},{"uid":"32","username":"Roar10","country":"Norway"},{"uid":"33","username":"Roar11","country":"Norway"},{"uid":"34","username":"Roar12","country":"Norway"},{"uid":"35","username":"Roar13","country":"Norway"},{"uid":"36","username":"Roar14","country":"Norway"},{"uid":"37","username":"Liv","country":"Norway"},{"uid":"38","username":"Liv1","country":"Norway"},{"uid":"39","username":"Liv2","country":"Norway"},{"uid":"40","username":"Roar15","country":"Norway"},{"uid":"41","username":"Liv3","country":"Norway"},{"uid":"42","username":"Roar16","country":"Norway"},{"uid":"43","username":"Roar17","country":"Norway"},{"uid":"44","username":"Roar18","country":"Norway"},{"uid":"45","username":"Roar19","country":"Norway"},{"uid":"46","username":"Peter","country":"Norway"},{"uid":"47","username":"Roar20","country":"Norway"},{"uid":"48","username":"Roar21","country":"Norway"},{"uid":"49","username":"Roar22","country":"Norway"},{"uid":"50","username":"Roar23","country":"Norway"},{"uid":"51","username":"44","country":""},{"uid":"52","username":"45","country":""},{"uid":"53","username":"Roar24","country":"Norway"},{"uid":"54","username":"Nimbus","country":"Namibia"},{"uid":"55","username":"Winnie","country":"USA"},{"uid":"56","username":"David","country":"Denmark"},{"uid":"57","username":"Frank","country":"Netherlands"},{"uid":"58","username":"David1","country":"Norway"},{"uid":"59","username":"Guttorm","country":"Great Britain"},{"uid":"60","username":"Maggie","country":"Finland"},{"uid":"61","username":"Roar25","country":"Norway"},{"uid":"62","username":"Lister","country":"England"},{"uid":"63","username":"OLJAOS","country":"NORWAY"},{"uid":"64","username":"frakk","country":"Nicaragua"},{"uid":"65","username":"Typo","country":"Iceland"},{"uid":"66","username":"Drop","country":"Norway"},{"uid":"67","username":"Super","country":"Norway"},{"uid":"68","username":"Wheels","country":"USA"},{"uid":"69","username":"Darya soleh","country":"Brunei"},{"uid":"70","username":"Kalianna","country":"Australia"},{"uid":"71","username":"Punyan","country":"Australia"},{"uid":"72","username":"Chali","country":"U.S. "},{"uid":"73","username":"Vivo","country":"lebanon"},{"uid":"74","username":"Kiran","country":"India"},{"uid":"75","username":"Arp","country":"India"},{"uid":"76","username":"Norman","country":"Deutschland"},{"uid":"77","username":"Katie","country":"England "},{"uid":"78","username":"Katie1","country":"England "},{"uid":"79","username":"Rose","country":" England"},{"uid":"80","username":"Rose1","country":" England"},{"uid":"81","username":"Mary49","country":"uk"},{"uid":"82","username":"Debbi","country":"USA"},{"uid":"83","username":"Heather","country":"Portugal"},{"uid":"84","username":"PS","country":"Australia"},{"uid":"85","username":"Tori","country":"Australia"},{"uid":"86","username":"Starman","country":"Bklyn "},{"uid":"87","username":"Ruru","country":"South Africa"},{"uid":"88","username":"Ruru1","country":"Soweto"},{"uid":"89","username":"Friendly","country":"New Zealand"},{"uid":"90","username":"Joomla","country":"Norway"},{"uid":"91","username":"Bram","country":"England"},{"uid":"92","username":"Tootsi","country":"Australia"},{"uid":"93","username":"Joseph","country":"Israel"},{"uid":"94","username":"Joseph1","country":"Israel"},{"uid":"95","username":"Ned","country":"England"},{"uid":"96","username":"Tipper","country":"Norway"},{"uid":"97","username":"PeterLG","country":"Norway"}],"success":1} Following files are viewed here: AsyncTest1.cbroj AsyncTest1.cpp AsyntTest1PCH1.h Unit1.cpp Unit1.fmx Unit1.h Unit2.cpp Unit2.h AsyncTest1.cbproj <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{F10FA286-4B97-4B99-B9ED-479230497009}</ProjectGuid>
<ProjectVersion>16.1</ProjectVersion>
<FrameworkType>FMX</FrameworkType>
<MainSource>AsyncTest1.cpp</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Android</Platform>
<TargetedPlatforms>16</TargetedPlatforms>
<AppType>Application</AppType>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Android' and '$(Base)'=='true') or '$(Base_Android)'!=''">
<Base_Android>true</Base_Android>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Android' and '$(Cfg_1)'=='true') or '$(Cfg_1_Android)'!=''">
<Cfg_1_Android>true</Cfg_1_Android>
<CfgParent>Cfg_1</CfgParent>
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
<AUP_READ_EXTERNAL_STORAGE>true</AUP_READ_EXTERNAL_STORAGE>
<AllPackageLibs>rtl.lib;fmx.lib;dbrtl.lib;FireDAC.lib;FireDACSqliteDriver.lib;FireDACCommonDriver.lib;FireDACCommon.lib;xmlrtl.lib;bindengine.lib;bindcomp.lib;IndyIPClient.lib;IndyIPCommon.lib;CustomIPTransport.lib;IndySystem.lib;IndyProtocols.lib;IndyCore.lib;RESTComponents.lib;bindcompfmx.lib</AllPackageLibs>
<AUP_ACCESS_FINE_LOCATION>true</AUP_ACCESS_FINE_LOCATION>
<AUP_ACCESS_COARSE_LOCATION>true</AUP_ACCESS_COARSE_LOCATION>
<ProjectType>FmxGuiApplication</ProjectType>
<Multithreaded>true</Multithreaded>
<AUP_CALL_PHONE>true</AUP_CALL_PHONE>
<AUP_CAMERA>true</AUP_CAMERA>
<SanitizedProjectName>AsyncTest1</SanitizedProjectName>
<AUP_READ_CALENDAR>true</AUP_READ_CALENDAR>
<AUP_INTERNET>true</AUP_INTERNET>
<AUP_WRITE_CALENDAR>true</AUP_WRITE_CALENDAR>
<AUP_WRITE_EXTERNAL_STORAGE>true</AUP_WRITE_EXTERNAL_STORAGE>
<AUP_READ_PHONE_STATE>true</AUP_READ_PHONE_STATE>
<_TCHARMapping>wchar_t</_TCHARMapping>
<DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
<DynamicRTL>true</DynamicRTL>
<UsePackages>true</UsePackages>
<IntermediateOutputDir>.\$(Platform)\$(Config)</IntermediateOutputDir>
<FinalOutputDir>.\$(Platform)\$(Config)</FinalOutputDir>
<BCC_wpar>false</BCC_wpar>
<BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
<BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
<ILINK_TranslatedLibraryPath>$(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath)</ILINK_TranslatedLibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Android)'!=''">
<Android_LauncherIcon48>$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_48x48.png</Android_LauncherIcon48>
<IncludePath>$(BDSINCLUDE)\android\fmx;$(IncludePath)</IncludePath>
<Android_LauncherIcon36>$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_36x36.png</Android_LauncherIcon36>
<Android_SplashImage960>$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_960x720.png</Android_SplashImage960>
<PackageImports>bindcomp;bindcompfmx;bindengine;CloudService;CustomIPTransport;dbrtl;DbxClientDriver;DbxCommonDriver;emsclient;emsclientfiredac;FireDAC;FireDACCommon;FireDACCommonDriver;FireDACIBDriver;FireDACSqliteDriver;fmx;fmxFireDAC;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;RESTBackendComponents;RESTComponents;rtl;soaprtl;tethering;xmlrtl;$(PackageImports)</PackageImports>
<Android_SplashImage470>$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_470x320.png</Android_SplashImage470>
<Android_LauncherIcon96>$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_96x96.png</Android_LauncherIcon96>
<Android_SplashImage426>$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_426x320.png</Android_SplashImage426>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<UsePackages>false</UsePackages>
<BCC_PCHName_Clang>AsyncTest1PCH1.h</BCC_PCHName_Clang>
<Android_LauncherIcon72>$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_72x72.png</Android_LauncherIcon72>
<BT_BuildType>Debug</BT_BuildType>
<Android_SplashImage640>$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_640x480.png</Android_SplashImage640>
<Android_LauncherIcon144>$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_144x144.png</Android_LauncherIcon144>
<VerInfo_Keys>package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true</VerInfo_Keys>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>
<BCC_DisableOptimizations>true</BCC_DisableOptimizations>
<DCC_Optimize>false</DCC_Optimize>
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
<Defines>_DEBUG;$(Defines)</Defines>
<BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>
<BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>
<DCC_Define>DEBUG</DCC_Define>
<BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>
<TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>
<BCC_StackFrames>true</BCC_StackFrames>
<ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>
<TASM_Debugging>Full</TASM_Debugging>
<BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>
<BCC_EnableCPPExceptions>true</BCC_EnableCPPExceptions>
<BCC_DisableFramePtrElimOpt>true</BCC_DisableFramePtrElimOpt>
<BCC_DisableSpellChecking>true</BCC_DisableSpellChecking>
<CLANG_UnwindTables>true</CLANG_UnwindTables>
<ILINK_LibraryPath>$(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>
<ILINK_TranslatedLibraryPath>$(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath)</ILINK_TranslatedLibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Android)'!=''">
<LinkPackageStatics>rtl.lib;fmx.lib;dbrtl.lib;FireDAC.lib;FireDACSqliteDriver.lib;FireDACCommonDriver.lib;FireDACCommon.lib;xmlrtl.lib;bindengine.lib;bindcomp.lib;IndyIPClient.lib;IndyIPCommon.lib;CustomIPTransport.lib;IndySystem.lib;IndyProtocols.lib;IndyCore.lib;RESTComponents.lib;bindcompfmx.lib</LinkPackageStatics>
<ILINK_LibraryPath>$(BDS)\lib\Android\debug\;$(ILINK_LibraryPath)</ILINK_LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<Defines>NDEBUG;$(Defines)</Defines>
<TASM_Debugging>None</TASM_Debugging>
</PropertyGroup>
<ItemGroup>
<CppCompile Include="AsyncTest1.cpp">
<BuildOrder>0</BuildOrder>
</CppCompile>
<PCHCompile Include="AsyncTest1PCH1.h">
<BuildOrder>2</BuildOrder>
<PCH>true</PCH>
</PCHCompile>
<CppCompile Include="Unit1.cpp">
<Form>Form1</Form>
<FormType>fmx</FormType>
<DependentOn>Unit1.h</DependentOn>
<BuildOrder>1</BuildOrder>
</CppCompile>
<CppCompile Include="Unit2.cpp">
<DependentOn>Unit2.h</DependentOn>
<BuildOrder>3</BuildOrder>
</CppCompile>
<FormResources Include="Unit1.fmx"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="Debug">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>CPlusPlusBuilder.Personality.12</Borland.Personality>
<Borland.ProjectType>FmxGuiApplication</Borland.ProjectType>
<BorlandProject>
<CPlusPlusBuilder.Personality>
<ProjectProperties>
<ProjectProperties Name="AutoShowDeps">False</ProjectProperties>
<ProjectProperties Name="ManagePaths">True</ProjectProperties>
<ProjectProperties Name="VerifyPackages">True</ProjectProperties>
<ProjectProperties Name="IndexFiles">False</ProjectProperties>
</ProjectProperties>
<Source>
<Source Name="MainSource">AsyncTest1.cpp</Source>
</Source>
</CPlusPlusBuilder.Personality>
<Deployment>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_48x48.png" Configuration="Debug" Class="Android_LauncherIcon48">
<Platform Name="Android">
<RemoteName>ic_launcher.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'=='true'" LocalName="$(BDS)\bin\cc32160mt.dll" Class="DependencyModule">
<Platform Name="Win32">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx32\libcgcrtl.dylib" Class="DependencyModule">
<Platform Name="OSX32">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_640x480.png" Configuration="Debug" Class="Android_SplashImage640">
<Platform Name="Android">
<RemoteName>splash_image.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_144x144.png" Configuration="Debug" Class="Android_LauncherIcon144">
<Platform Name="Android">
<RemoteName>ic_launcher.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_960x720.png" Configuration="Debug" Class="Android_SplashImage960">
<Platform Name="Android">
<RemoteName>splash_image.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName=".\Android\Debug\styles.xml" Configuration="Debug" Class="AndroidSplashStyles">
<Platform Name="Android">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="c:\program files (x86)\embarcadero\studio\15.0\lib\android\debug\mips\libnative-activity.so" Configuration="Debug" Class="AndroidLibnativeMipsFile">
<Platform Name="Android">
<RemoteName>libAsyncTest1.so</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="C:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\android-ndk-r9c\prebuilt\android-arm\gdbserver\gdbserver" Configuration="Debug" Class="AndroidGDBServer">
<Platform Name="Android">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName=".\Android\Debug\libAsyncTest1.so" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Android">
<RemoteName>libAsyncTest1.so</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'=='true'" LocalName="$(BDS)\bin64\cc64160mt.dll" Class="DependencyModule">
<Platform Name="Win64">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="OSX32">
<Overwrite>true</Overwrite>
</Platform>
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_72x72.png" Configuration="Debug" Class="Android_LauncherIcon72">
<Platform Name="Android">
<RemoteName>ic_launcher.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="c:\program files (x86)\embarcadero\studio\15.0\lib\android\debug\classes.dex" Configuration="Debug" Class="AndroidClassesDexFile">
<Platform Name="Android">
<RemoteName>classes.dex</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_470x320.png" Configuration="Debug" Class="Android_SplashImage470">
<Platform Name="Android">
<RemoteName>splash_image.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_SplashImage_426x320.png" Configuration="Debug" Class="Android_SplashImage426">
<Platform Name="Android">
<RemoteName>splash_image.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(UsingDelphiRTL)'=='true'" LocalName="$(BDS)\bin\borlndmm.dll" Class="DependencyModule">
<Platform Name="Win32">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="c:\program files (x86)\embarcadero\studio\15.0\lib\android\debug\x86\libnative-activity.so" Configuration="Debug" Class="AndroidLibnativeX86File">
<Platform Name="Android">
<RemoteName>libAsyncTest1.so</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'!='true'" LocalName="$(BDS)\bin\cc32160.dll" Class="DependencyModule">
<Platform Name="Win32">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(UsingDelphiRTL)'=='true'" LocalName="$(BDS)\bin64\borlndmm.dll" Class="DependencyModule">
<Platform Name="Win64">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName=".\Android\Debug\splash_image_def.xml" Configuration="Debug" Class="AndroidSplashImageDef">
<Platform Name="Android">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="c:\program files (x86)\embarcadero\studio\15.0\lib\android\debug\armeabi\libnative-activity.so" Configuration="Debug" Class="AndroidLibnativeArmeabiFile">
<Platform Name="Android">
<RemoteName>libAsyncTest1.so</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_96x96.png" Configuration="Debug" Class="Android_LauncherIcon96">
<Platform Name="Android">
<RemoteName>ic_launcher.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName=".\Android\Debug\AndroidManifest.xml" Configuration="Debug" Class="ProjectAndroidManifest">
<Platform Name="Android">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Appmethod\Android\FM_LauncherIcon_36x36.png" Configuration="Debug" Class="Android_LauncherIcon36">
<Platform Name="Android">
<RemoteName>ic_launcher.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx32\libcgstl.dylib" Class="DependencyModule">
<Platform Name="OSX32">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'!='true'" LocalName="$(BDS)\bin64\cc64160.dll" Class="DependencyModule">
<Platform Name="Win64">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployClass Required="true" Name="DependencyPackage">
<Platform Name="iOSDevice">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.bpl</Extensions>
</Platform>
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
</DeployClass>
<DeployClass Name="DependencyModule">
<Platform Name="iOSDevice">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
</Platform>
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXInfoPList">
<Platform Name="OSX32">
<RemoteDir>Contents</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice">
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage470">
<Platform Name="Android">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeX86File">
<Platform Name="Android">
<RemoteDir>library\lib\x86</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSResource">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXEntitlements">
<Platform Name="OSX32">
<RemoteDir>../</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidGDBServer">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch640">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage960">
<Platform Name="Android">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch320">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon144">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeMipsFile">
<Platform Name="Android">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashImageDef">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DebugSymbols">
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DependencyFramework">
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage426">
<Platform Name="Android">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSEntitlements">
<Platform Name="iOSDevice">
<RemoteDir>../</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidClassesDexFile">
<Platform Name="Android">
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSInfoPList">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1024">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_DefaultAppIcon">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXResource">
<Platform Name="OSX32">
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceResourceRules">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch768">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Required="true" Name="ProjectOutput">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiFile">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage640">
<Platform Name="Android">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="File">
<Platform Name="iOSDevice">
<Operation>0</Operation>
</Platform>
<Platform Name="Android">
<Operation>0</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>0</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch640x1136">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStyles">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1536">
<Platform Name="iOSDevice">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectAndroidManifest">
<Platform Name="Android">
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Android" ActiveMobileDevice="989b5b4d">True</Platform>
</Platforms>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
<Import Project="$(BDS)\Bin\CodeGear.Cpp.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Cpp.Targets')"/>
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
<Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"/>
</Project>
AsyncTest1.cpp //---------------------------------------------------------------------------
#include <fmx.h>
#ifdef _WIN32
#include <tchar.h>
#endif
#pragma hdrstop
#include <System.StartUpCopy.hpp>
//---------------------------------------------------------------------------
USEFORM("Unit1.cpp", Form1);
//---------------------------------------------------------------------------
extern "C" int FMXmain()
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
AsyncTest1PCH1.h #include <fmx.h>
#ifdef _WIN32
#include <tchar.h>
#endif
Unit1.cpp //---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
TMyThread *MyThread;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
MyThread = new TMyThread(true,RESTRequest1); //true = CreateSuspended
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExecuteClick(TObject *Sender)
{
RESTRequest1->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExecuteAsyncClick(TObject *Sender)
{
RESTRequest1->ExecuteAsync();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnTTaskClick(TObject *Sender)
{
TTask::Run(_di_TProc(new TCppTask(RESTRequest1)));
}
//---------------------------------------------------------------------------
//== class TCppTask ===
void __fastcall TCppTask::Invoke()
{
Task_RESTRequest->Execute();
TThread::Synchronize(0,_di_TThreadProcedure(new TCppSync(Task_RESTRequest)));
}
//---------------------------------------------------------------------------
//== class TCppSync ===
void __fastcall TCppSync :: Invoke()
{
Form1->RESTRequest1 = Sync_RESTRequest;
}
void __fastcall TForm1::btnTThreadClick(TObject *Sender)
{
//MyThread->initData(RESTRequest1);
MyThread->Execute();
}
//---------------------------------------------------------------------------
Unit1.fmx object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 615
ClientWidth = 350
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
DesignerMasterStyle = 3
object StringGrid1: TStringGrid
Position.X = 32.000000000000000000
Position.Y = 328.000000000000000000
Size.Width = 281.000000000000000000
Size.Height = 249.000000000000000000
Size.PlatformDefault = False
TabOrder = 10
RowCount = 0
RowHeight = 21.000000000000000000
end
object btnExecute: TButton
Position.X = 32.000000000000000000
Position.Y = 224.000000000000000000
Size.Width = 113.000000000000000000
Size.Height = 44.000000000000000000
Size.PlatformDefault = False
TabOrder = 11
Text = 'Execute()'
OnClick = btnExecuteClick
end
object btnExecuteAsync: TButton
Position.X = 152.000000000000000000
Position.Y = 224.000000000000000000
Size.Width = 161.000000000000000000
Size.Height = 44.000000000000000000
Size.PlatformDefault = False
TabOrder = 12
Text = 'ExecuteAsync()'
OnClick = btnExecuteAsyncClick
end
object btnTTask: TButton
Position.X = 32.000000000000000000
Position.Y = 272.000000000000000000
Size.Width = 113.000000000000000000
Size.Height = 44.000000000000000000
Size.PlatformDefault = False
TabOrder = 27
Text = 'TTask'
OnClick = btnTTaskClick
end
object ScrollBar1: TScrollBar
SmallChange = 0.000000000000000000
Orientation = Horizontal
Position.X = 24.000000000000000000
Position.Y = 152.000000000000000000
Size.Width = 297.000000000000000000
Size.Height = 41.000000000000000000
Size.PlatformDefault = False
object FloatAnimation1: TFloatAnimation
AutoReverse = True
Enabled = True
Duration = 1.000000000000000000
Loop = True
PropertyName = 'Value'
StartValue = 0.000000000000000000
StopValue = 100.000000000000000000
end
end
object btnTThread: TButton
Position.X = 152.000000000000000000
Position.Y = 272.000000000000000000
Size.Width = 161.000000000000000000
Size.Height = 44.000000000000000000
Size.PlatformDefault = False
TabOrder = 29
Text = 'TThread'
OnClick = btnTThreadClick
end
object RESTClient1: TRESTClient
Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,'
AcceptCharset = 'UTF-8, *;q=0.8'
AcceptEncoding = 'identity'
BaseURL = 'http://www.tileblock.com'
Params = <>
HandleRedirects = True
Left = 24
Top = 80
end
object RESTRequest1: TRESTRequest
Client = RESTClient1
Params = <>
Resource = 'scoreboard/list_users.php'
Response = RESTResponse1
Left = 104
Top = 8
end
object RESTResponse1: TRESTResponse
ContentType = 'text/html'
Left = 96
Top = 88
end
object RESTResponseDataSetAdapter1: TRESTResponseDataSetAdapter
Active = True
Dataset = FDMemTable1
FieldDefs = <>
ResponseJSON = RESTResponse1
RootElement = 'tileblockusers'
Left = 192
Top = 32
end
object FDMemTable1: TFDMemTable
Active = True
FieldDefs = <
item
Name = 'uid'
DataType = ftWideString
Size = 255
end
item
Name = 'username'
DataType = ftWideString
Size = 255
end
item
Name = 'country'
DataType = ftWideString
Size = 255
end>
IndexDefs = <>
FetchOptions.AssignedValues = [evMode]
FetchOptions.Mode = fmAll
ResourceOptions.AssignedValues = [rvSilentMode]
ResourceOptions.SilentMode = True
UpdateOptions.AssignedValues = [uvCheckRequired]
UpdateOptions.CheckRequired = False
AutoCommitUpdates = False
StoreDefs = True
Left = 288
Top = 16
object FDMemTable1uid: TWideStringField
FieldName = 'uid'
Size = 255
end
object FDMemTable1username: TWideStringField
FieldName = 'username'
Size = 255
end
object FDMemTable1country: TWideStringField
FieldName = 'country'
Size = 255
end
end
object BindSourceDB1: TBindSourceDB
DataSet = FDMemTable1
ScopeMappings = <>
Left = 184
Top = 96
end
object BindingsList1: TBindingsList
Methods = <>
OutputConverters = <>
Left = 28
Top = 21
object LinkGridToDataSourceBindSourceDB1: TLinkGridToDataSource
Category = 'Quick Bindings'
DataSource = BindSourceDB1
GridControl = StringGrid1
Columns = <>
end
end
end Unit1.h //---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <System.Threading.hpp> //Manually added for TTask and TThread
#include <FMX.Controls.hpp>
#include <FMX.Forms.hpp>
#include <Data.Bind.Components.hpp>
#include <Data.Bind.DBScope.hpp>
#include <Data.Bind.EngExt.hpp>
#include <Data.Bind.Grid.hpp>
#include <Data.Bind.ObjectScope.hpp>
#include <Data.DB.hpp>
#include <FireDAC.Comp.Client.hpp>
#include <FireDAC.Comp.DataSet.hpp>
#include <FireDAC.DApt.Intf.hpp>
#include <FireDAC.DatS.hpp>
#include <FireDAC.Phys.Intf.hpp>
#include <FireDAC.Stan.Error.hpp>
#include <FireDAC.Stan.Intf.hpp>
#include <FireDAC.Stan.Option.hpp>
#include <FireDAC.Stan.Param.hpp>
#include <Fmx.Bind.DBEngExt.hpp>
#include <Fmx.Bind.Editors.hpp>
#include <Fmx.Bind.Grid.hpp>
#include <FMX.Grid.hpp>
#include <FMX.Layouts.hpp>
#include <FMX.StdCtrls.hpp>
#include <FMX.Types.hpp>
#include <IPPeerClient.hpp>
#include <REST.Client.hpp>
#include <REST.Response.Adapter.hpp>
#include <System.Bindings.Outputs.hpp>
#include <System.Rtti.hpp>
#include <FMX.Ani.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TRESTClient *RESTClient1;
TRESTRequest *RESTRequest1;
TRESTResponse *RESTResponse1;
TRESTResponseDataSetAdapter *RESTResponseDataSetAdapter1;
TFDMemTable *FDMemTable1;
TStringGrid *StringGrid1;
TButton *btnExecute;
TButton *btnExecuteAsync;
TWideStringField *FDMemTable1uid;
TWideStringField *FDMemTable1username;
TWideStringField *FDMemTable1country;
TBindSourceDB *BindSourceDB1;
TBindingsList *BindingsList1;
TLinkGridToDataSource *LinkGridToDataSourceBindSourceDB1;
TButton *btnTTask;
TScrollBar *ScrollBar1;
TButton *btnTThread;
TFloatAnimation *FloatAnimation1;
void __fastcall btnExecuteClick(TObject *Sender);
void __fastcall btnExecuteAsyncClick(TObject *Sender);
void __fastcall btnTTaskClick(TObject *Sender);
void __fastcall btnTThreadClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
//---------------------------------------------------------------------------
};
class TCppTask : public TCppInterfacedObject<TProc>
{
TRESTRequest *Task_RESTRequest;
public:
TCppTask(TRESTRequest *i_RESTRequest):Task_RESTRequest(i_RESTRequest)
{}
void __fastcall Invoke();
};
//---------------------------------------------------------------------------
class TCppSync : public TCppInterfacedObject<TThreadProcedure>
{
TRESTRequest *Sync_RESTRequest;
public:
TCppSync(TRESTRequest *s_RESTRequest):Sync_RESTRequest(s_RESTRequest)
{}
void __fastcall Invoke();
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit2.cpp //---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#include "Unit2.h"
#include "unit1.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(&UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall TMyThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall TMyThread::TMyThread(bool CreateSuspended, TRESTRequest *init_Thread_RESTRequest)
: TThread(CreateSuspended), Thread_RESTRequest(init_Thread_RESTRequest)
{
// this->FreeOnTerminate=true;
}
//---------------------------------------------------------------------------
/*
void __fastcall TMyThread::initData(TRESTRequest *init_Thread_RESTRequest)
{
Thread_RESTRequest=init_Thread_RESTRequest;
} */
//---------------------------------------------------------------------------
void __fastcall TMyThread::Execute()
{
NameThreadForDebugging(System::String(L"MyThreadName"));
//---- Place thread code here ----
Thread_RESTRequest->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TMyThread::OnTerminate()
{
; //Empty at the moment -- cleanup
} Unit2.h //---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <unit1.h>
//---------------------------------------------------------------------------
class TMyThread : public TThread
{
protected:
TRESTRequest *Thread_RESTRequest;
public:
void __fastcall Execute();
// void __fastcall initData(TRESTRequest *init_Thread_RESTRequest);
__fastcall TMyThread(bool CreateSuspended,
TRESTRequest *init_Thread_RESTRequest);
void __fastcall OnTerminate();
};
//---------------------------------------------------------------------------
#endif
This happens when clicking each of the four buttons: Execute(): Runs the TRESTRequest->Execute() function, works as expected: the autosliding scrollbar lags. 2nd and 3rd clicks also ok, lags as expected. ExecuteAsync(): Works in approx 70% of first clicks, subsequent clicks (2 or 3 times) crashes application with arbitrary results. When it works, autoslider does not lag. TTask: Works in 80% of first clicks, subsequent clicks (2-4 times) crashes appication with abitrary results. When it works, autoslider does not lag. TThread: Seems to work as Execute(), the autoslider lags. Is stable with subsequent clicks. (May be the TThread function is not used the correct way ?) Please take a survey inot the code, copy / paste the code and give me some feedback. Maybe I have forgotten something obvios. RG |
|
Moderators: April Anne