We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threads
#1
If i have a program and call a subroutine in that program from the UI thread, will it still be on the UI thread or does it run on a different thread?

JR
Reply
#2
Small Basic Threading : https://learn.microsoft.com/en-us/archiv...-threading

I have created Threading Object In My Extension from long time i should post the extension now it contains many new things.
ZS
[-] The following 2 users Like z-s's post:
  • AbsoluteBeginner, jrmrhrb00
Reply
#3
Z-S,

I had read that article before. Good to read and study it again. I think the answer to my question is a called subroutine will run in its own thread. I wonder if there is a way to test it. Is there some way to see the thread you are running on?

JR
Reply
#4
(11-25-2024, 12:12 PM)jrmrhrb00 Wrote: Z-S,

... I think the answer to my question is a called subroutine will run in its own thread...

JR

Hi, JR  Shy

You are wrong. If the subroutine was called by a UI thread, then the subroutine will be executed in the UI thread.
If the subroutine is called by an event handler, then the subroutine will run in a separate thread of its own.

In addition, a method in the LitDev library allows you to call a subroutine to work in a separate thread:
LDCall.CallAsync(dll, extension, obj, method, arguments)

Shy
Reply
#5
AB Is right and you could see threads of a exe in resmon google it.
ZS
Reply
#6
Well, on the internet it says this:

Subroutines in Small Basic do not run on the UI thread. So, that leaves me with I just don't know. I tried resmon, but it just shows all threads, not if it is running on Ui.

JR
Reply
#7
In this case, we will wait for LitDev's response.  Shy
Reply
#8
I think AB answer is right, don't believe everything internet says, especially if it came from AI!

If there is specific issue or question on this in addition to the general one then please ask.
[-] The following 1 user Likes litdev's post:
  • jrmrhrb00
Reply
#9
LitDev,

I really don't know. Is there any way that you know of that shows if you are running in the UI thread?

This could make a major difference in some programs. Say you have a bunch of events where the code in them is too long. So in the front of these events you put a flag and put the excess code in a subroutine. Then in the main code you put an if statement followed by another flag which says true, followed by a call to the sub routine that has the excess code in it. That way your running in the UI and doing updates as needed. So, it would be great if it actually works that way! That way you don't have to move the excess code. Just make it a subroutine!

JR

PS I hope I didn't confuse anybody.
Reply
#10
Currentthread property.
May be I could provide in next extension update.
ZS
[-] The following 2 users Like z-s's post:
  • AbsoluteBeginner, jrmrhrb00
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)