diff options
author | John Ankarström <john@ankarstrom.se> | 2022-06-06 00:24:13 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-06-06 00:24:13 +0200 |
commit | c50bade7dd390784454e44a54a6bcac515d80531 (patch) | |
tree | 95ac44bfbb5d9992212b4d17531e9de5b238314c /c/main.c | |
parent | f9dc17e285b5d3100d3eb6dc80a38a621fafe1ae (diff) | |
download | EpisodeBrowser-c50bade7dd390784454e44a54a6bcac515d80531.tar.gz |
Add basic threading support.
It is much easier to implement on the Prolog side than on the C
side... :-)
Diffstat (limited to 'c/main.c')
-rw-r--r-- | c/main.c | 39 |
1 files changed, 33 insertions, 6 deletions
@@ -6,6 +6,7 @@ #include "resource.h" #include "defs.h" +atom_t AThread; char SzLimitScreenwriter[64] = {0}; HFONT HfNormal; HFONT HfBold; @@ -15,6 +16,7 @@ HWND HWnd; HWND HWndStatus; int BViewTVOriginal = 1; int BViewWatched = 1; +int BThread = 0; int IDPI = -1; static int BThemes; static int CxVScroll; @@ -203,6 +205,27 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return ElvHandleNotify(lParam); } break; + case WM_TIMER: + switch (wParam) { + case IDT_TIMER: + { + static int i = 0; + if (Pl("episode_data","thread_running","A",AThread)) { + i = (i+1)%4; + SendMessage(HWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), + (LPARAM)(i==0? TEXT("."): + i==1? TEXT(".."): + i==2? TEXT("..."): + TEXT(""))); + } else { + i = 0; + KillTimer(hWnd, IDT_TIMER); + ElvUpdate(); + } + break; + } + } + break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_FILE_EXIT: @@ -212,12 +235,16 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ElvUpdate(); break; case IDM_FILE_FETCH_DATA: - Pl("episode_data","update_episode_data",""); - ElvUpdate(); - break; + if (BThread) break; + Pl("episode_data","thread_create","Sa","update_episode_data",&AThread); + goto t; case IDM_FILE_FETCH_SCREENWRITERS: - Pl("episode_data","update_screenwriters",""); - ElvUpdate(); + if (BThread) break; + Pl("episode_data","thread_create","Sa","update_screenwriters",&AThread); + t: KillTimer(hWnd, IDT_TIMER); + SetTimer(hWnd, IDT_TIMER, 500, NULL); + SendMessage(HWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), (LPARAM)TEXT(".")); + BThread = 1; break; case IDM_FILE_ABOUT: DialogBox( @@ -514,7 +541,7 @@ UpdateLayout() /* Resize status bar parts. */ { - int aParts[] = {rc.right-Dpi(100), rc.right-Dpi(50), rc.right}; + int aParts[] = {rc.right-Dpi(55), rc.right}; SendMessage(HWndStatus, SB_SETPARTS, (WPARAM)sizeof(aParts), (LPARAM)aParts); } |