{"id":21070841,"url":"https://github.com/fafalone/threadtest","last_synced_at":"2025-06-29T07:35:02.209Z","repository":{"id":151901741,"uuid":"549190433","full_name":"fafalone/ThreadTest","owner":"fafalone","description":"twinBASIC mutltithreading proof of concept","archived":false,"fork":false,"pushed_at":"2023-02-26T09:18:39.000Z","size":40,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T21:56:52.154Z","etag":null,"topics":["multithreading","twinbasic","vb6"],"latest_commit_sha":null,"homepage":"","language":"Visual Basic 6.0","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fafalone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-10T20:18:54.000Z","updated_at":"2023-12-11T04:32:02.000Z","dependencies_parsed_at":"2023-05-15T02:00:16.751Z","dependency_job_id":null,"html_url":"https://github.com/fafalone/ThreadTest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FThreadTest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FThreadTest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FThreadTest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FThreadTest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fafalone","download_url":"https://codeload.github.com/fafalone/ThreadTest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243513880,"owners_count":20303028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multithreading","twinbasic","vb6"],"created_at":"2024-11-19T18:48:34.268Z","updated_at":"2025-03-14T02:42:48.196Z","avatar_url":"https://github.com/fafalone.png","language":"Visual Basic 6.0","readme":"# ThreadTest\n\nExtremely simple demo of multithreading in twinBASIC\n\nNormally, when you call MsgBox, code execution stops until you respond to it. In this demo, you'll see the following line continues and updates the label, before we decide to manually wait for it.\n\n(Feb 24th 2023: Updated to use a TextBox instead of a label due to a rendering issue with lightweight controls not updating immediately; UI improvements)\n\n(Nov 9th 2022: Updated for x64/bugfixes)\n\n---\n\nThis is just a simple proof-of-concept showing you can safely multithread in twinBASIC via API without relying on the elaborate hacks VB6 requires to call `CreateThread`:\n\n```\n    Private Declare PtrSafe Function GetCurrentThreadId Lib \"kernel32\" () As Long\n\n    Private Declare PtrSafe Function CreateThread Lib \"kernel32\" ( _\n                            ByRef lpThreadAttributes As Any, _\n                            ByVal dwStackSize As Long, _\n                            ByVal lpStartAddress As LongPtr, _\n                            ByRef lpParameter As Any, _\n                            ByVal dwCreationFlags As Long, _\n                            ByRef lpThreadId As Long) As LongPtr\n\n    Private Declare PtrSafe Function WaitForSingleObject Lib \"kernel32\" ( _\n                            ByVal hHandle As LongPtr, _\n                            ByVal dwMilliseconds As Long) As Long\n\n \n    \n    Private Const INFINITE = -1\u0026\n    \n    Private Sub Command1_Click() Handles Command1.Click\n        Dim lTID As Long\n        Dim lCurTID As Long\n        Dim hThreadNew As LongPtr\n        lCurTID = GetCurrentThreadId()\n        hThreadNew = CreateThread(ByVal 0, 0, AddressOf TestThread, ByVal 0, 0, lTID)\n        Text1.Text = \"Thread \" \u0026 lCurTID \u0026 \" is waiting on thread \" \u0026 lTID\n        Dim hr As Long\n        hr = WaitForSingleObject(hThreadNew, 30000\u0026) 'Wait 30s as a default. You can use INFINITE instead if you never want to time out.\n        Text1.Text = \"Wait end code \" \u0026 CStr(hr)\n    End Sub\n\n    Public Sub TestThread()\n        MsgBox \"Hello thread\"\n    End Sub\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffafalone%2Fthreadtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffafalone%2Fthreadtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffafalone%2Fthreadtest/lists"}