+LONG WINAPI UserUnhandledExceptionFilter(EXCEPTION_POINTERS* info)\r
+{\r
+ try\r
+ {\r
+ CASPAR_LOG(fatal) << L"#######################\n UNHANDLED EXCEPTION: \n" \r
+ << L"Adress:" << info->ExceptionRecord->ExceptionAddress << L"\n"\r
+ << L"Code:" << info->ExceptionRecord->ExceptionCode << L"\n"\r
+ << L"Flag:" << info->ExceptionRecord->ExceptionFlags << L"\n"\r
+ << L"Info:" << info->ExceptionRecord->ExceptionInformation << L"\n"\r
+ << L"Continuing execution. \n#######################";\r
+ }\r
+ catch(...){}\r
+\r
+ return EXCEPTION_CONTINUE_EXECUTION;\r
+}\r
+\r
+int main(int argc, wchar_t* argv[])\r
+{ \r
+ static_assert(sizeof(void*) == 4, "64-bit code generation is not supported.");\r
+ \r
+ SetUnhandledExceptionFilter(UserUnhandledExceptionFilter);\r
+\r
+ CASPAR_LOG(info) << L"Type \"q\" to close application";\r
+\r
+ CASPAR_LOG(info) << L"THIS IS AN ALPHA BUILD";\r
+\r
+ // Set debug mode.\r
+ #ifdef _DEBUG\r
+ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );\r
+ _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );\r
+ _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG );\r
+ _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );\r
+ #endif\r
+\r
+ // Increase process priotity.\r
+ SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);\r
+\r
+ // Install structured exception handler.\r
+ caspar::win32_exception::install_handler();\r
+ \r
+ // Increase time precision. This will increase accuracy of function like Sleep(1) from 10 ms to 1 ms.\r
+ struct inc_prec\r
+ {\r
+ inc_prec(){timeBeginPeriod(1);}\r
+ ~inc_prec(){timeEndPeriod(1);}\r
+ } inc_prec; \r
+\r
+ // Install unstructured exception handlers into all tbb threads.\r
+ struct tbb_thread_installer : public tbb::task_scheduler_observer\r
+ {\r
+ tbb_thread_installer(){observe(true);}\r
+ void on_scheduler_entry(bool is_worker)\r
+ {\r
+ //caspar::detail::SetThreadName(GetCurrentThreadId(), "tbb-worker-thread");\r
+ caspar::win32_exception::install_handler();\r
+ }\r
+ } tbb_thread_installer;\r
+\r
+ tbb::task_scheduler_init init;\r
+ \r