No Description

TestApp1.cpp 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // TestApp1.cpp : Defines the entry point for the application.
  2. //
  3. #ifdef _WIN32
  4. #include "Win32/stdafx.h"
  5. #endif
  6. #include <DK.h>
  7. class TestApp1 : public DKApplication
  8. {
  9. DKObject<DKThread> thread;
  10. public:
  11. void OnInitialize(void) override
  12. {
  13. DKLog("%s", __PRETTY_FUNCTION__);
  14. DKLog("---- SystemPath ----");
  15. DKLog("SystemRoot: %ls", (const wchar_t*)DefaultPath(SystemPath::SystemRoot));
  16. DKLog("AppRoot: %ls", (const wchar_t*)DefaultPath(SystemPath::AppRoot));
  17. DKLog("AppResource: %ls", (const wchar_t*)DefaultPath(SystemPath::AppResource));
  18. DKLog("AppExecutable: %ls", (const wchar_t*)DefaultPath(SystemPath::AppExecutable));
  19. DKLog("AppData: %ls", (const wchar_t*)DefaultPath(SystemPath::AppData));
  20. DKLog("UserHome: %ls", (const wchar_t*)DefaultPath(SystemPath::UserHome));
  21. DKLog("UserDocuments: %ls", (const wchar_t*)DefaultPath(SystemPath::UserDocuments));
  22. DKLog("UserPreferences: %ls", (const wchar_t*)DefaultPath(SystemPath::UserPreferences));
  23. DKLog("UserCache: %ls", (const wchar_t*)DefaultPath(SystemPath::UserCache));
  24. DKLog("UserTemp: %ls", (const wchar_t*)DefaultPath(SystemPath::UserTemp));
  25. DKLog("---- ProcessInfo ----");
  26. DKLog("HostName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::HostName));
  27. DKLog("OsName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::OsName));
  28. DKLog("UserName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::UserName));
  29. DKLog("ModulePath: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::ModulePath));
  30. thread = DKThread::Create(DKFunction([this]()
  31. {
  32. DKLog("Running new thread!");
  33. this->EventLoop()->Post(DKFunction([&]()
  34. {
  35. DKLog("test1");
  36. })->Invocation(), 2);
  37. this->EventLoop()->Post(DKFunction([&]()
  38. {
  39. DKLog("test2");
  40. })->Invocation(), 4);
  41. this->EventLoop()->Post(DKFunction([&]()
  42. {
  43. DKLog("Terminate!!");
  44. DKApplication::Instance()->Terminate(0);
  45. })->Invocation(), 10);
  46. })->Invocation());
  47. }
  48. void OnTerminate(void) override
  49. {
  50. DKLog("%s", __PRETTY_FUNCTION__);
  51. DKLog("Waiting for worker thread!");
  52. thread->WaitTerminate();
  53. }
  54. };
  55. #ifdef _WIN32
  56. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  57. _In_opt_ HINSTANCE hPrevInstance,
  58. _In_ LPWSTR lpCmdLine,
  59. _In_ int nCmdShow)
  60. #else
  61. int main(int argc, const char * argv[])
  62. #endif
  63. {
  64. TestApp1 app;
  65. DKPropertySet::SystemConfig().SetValue("AppDelegate", "AppDelegate");
  66. return app.Run();
  67. }