As long as you had optimised compiled it then no! Can you post the code you tried?Any idea why that wouldn't work?
The second paragraph of Overview in the helpIs that creating problems, in other words, do I have to make an exe to test it properly?
Threading does not work in the IDE as that is a byte-code environment (known as legacy mode to us cognoscentiThe Thread object of this library is intended for use with the optimising compiler of Basic4PPC version 6 onwards. However it can run, after a fashion, in the IDE and in a legacy compiled application. The library protects itself, and you, if it finds itself running in a legacy mode and issues warnings that functions are not available. The purpose of allowing this is to enable debugging of thread code in the IDE because debugging a compiled application is more tricky than using the debugger in the IDE.
That's the library warning you that threading is not available in the legacy environment.Also, I'm confused by the 'legacy mode' message box I keep getting when run from the IDE. Does that mean I don't have all the required up-to-date stuff (I thought I had the latest versions of everything), or do I just get that because I'm running from the IDE?
I don't understand this. Optimising is a global variable and in the demo it is set true, so unless you have set it false that commenting out should do nothing. You shouldn't be getting a legacy message anyway if you are running an optimised compiled app.I commented out the ThreadCode line so nothing would happen until I pressed the start button because the legacy message was getting in the way, and I needed to be able to clear that first to test it properly?
You are optimising compiling this to run it aren't you? I can't easily dump my network connection but I've run the following code as you have described, adding a line to see the response and a duff URL that causes a couple of seconds delay before GetResponse returns. Pressing the Join button reports that the thread is running showing that my user interface is alive during this time as I would expect.So can you see any reason why the http request jams up everything?
Response.New1
Request.New1("http://www.dac")
'This line calls the server and gets the response.
Response.Value = Request.GetResponse
tb1text = Response.GetString ' added to see the response
Thread.FireThreadEvent
Exactly! As I noted previously threading is not possible in the byte-coded legacy environments of the IDE and non-optimised compiled exes. That's why I implemented the legacy warnings.do you mean I have to compile it into an exe for it to work properly?
It runs, but not as a background task and not without modifying my demo code. Set the global variable Optimising to false and it runs under the IDE. This demo is structured to show how code could be tested in the IDE without threading and then run compiled as a threaded app.I'm confused because your 1000 loop example seems to run fine in the IDE as a background task when I test it.
Sub ThreadCode
ErrorLabel(ThreadCodeErr1)
'try to fetch data from server
Response.New1
Request.New1("myURL")
'This line calls the server and gets the response.
Response.Value = Request.GetResponse
'did we get data? if we hit next line, we did
tb1text = "ok"
Thread.FireThreadEvent ' update textbox
Msgbox(Response.GetString)
Return
'program flow should go here if there's no internet found or other error
ThreadCodeErr1:
tb1text = "not ok"
Thread.FireThreadEvent ' update text box
End Sub
Note he said after not in -possibly big difference.Hi Andrew, that's good news from Erel about adding asynchronous communication support in the next release.
They are useful when two threads need to update or use the same resource such as a global variable or a Serial Port or some other resource that only supports a single method of access. The "Thread safety" section in the "Thread pitfalls" topic of the help tries to explain this.I don't understand what these routines are about
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?