Many questions about Xojo

Primarily, cross platform debugging. I’ve also used the remote debugger to debug cross site.

Executables built with Xojo are fundamentally single threaded and procedural. Xojo Event handlers are merely functions and subroutines that the Xojo framework knows how and in what order to call.

A GUI requires some form of multi-tasking. Xojo GUI applications use co-operative multi-tasking, similar to Win16 (Win 3 and Win 95). Xojo Event handlers must return control to the framework in a timely manner to allow the framework to update GUI elements Etc, otherwise the application will fail to respond to GUI events. Xojo Timers and Xojo Threads are particular types of event handler that abstract the single-threaded-ness and ease the burdens of chopping up multiple tasks into small slices of execution time.

Co-operative multi-tasking can provide Xojo applications with the appearance of doing two things simultaneously. However, the single thread is also used for i/o that is relatively slow. Semaphores provide a structure for controlling acccess to resources shared by separate tasks. For instance you might have two event handlers holding the same file open and attempting to write chunks to it between returns to the framework.

When you really do want a separate thread.

In simple terms. Xojo GUI applicaitons are event driven. A Worker provides a way to break out of the co-operative event driven paradigm. A worker is compiled as a separate Xojo console application - A separate executable task that is assigned a separate thread by the operating system. The worker application does not have a GUI, so does not need to cooperate with Xojo’s GUI framework.

An example of a Xojo worker? I’ve never used the Xojo Worker facility but was using the design pattern well before it became integrated into the IDE. I have some applications that separate the GUI from network communcations. Let’s say I want to provide an interface to gather user input before kicking off a series of non-visual sequential tasks - For instance, uploading files in a particular order. The GUI applicaiton gathers the input, writes a control file and then triggers a separate console application to sequence the uploads. The operating system spawns a new thread for the upload sequence, leaving the GUI app to carry on regardless, responding to GUI events.

Delegates are similar to function pointers in C and C++. Event handlers are essentially pointers to functions which the framework knows how to call. A Delegate is the type of the address the pointer is pointing to. Delegates provide a powerful means to implement polymorphism by hooking event handlers and registering call backs.

Yes. That sequential upload using a seperate console application I mentioned earlier. Let’s say I want to message the GUI application to let the user know the sequence completed successfully or with some error or other. I could use an IPC socket to do that.

A memory block is the closest thing Xojo has to a void type. A use case? That sequential upload application once more. Rather than writing a control structure to a file, I could write the control structure to a memory block and write the memory block to an IPC Socket connected to the console application.

Do test early and often. Don’t expect everything to work perfectly or consistently.

2 Likes

Sometimes, wikipedia is your friend.

Of course, asking here is good too. :japanese_ogre:

I used Timers when I had to get data from an online API. Because I had sent a request with data, had to wait until the processing finished and ask multiple times if the result is ready to be received. And I think there is no way around using Timers, if you don’t know whether the data already processed from your online API endpoint or not.

From my point of view, a Thread is nothing else than just an asynchronous operation that I can call to fulfill specific processes, like for example file uploading, rendering, processing large files, etc.
I know that concept from other programming languages.

Wouldn’t that be just a microservice? And again, that concept is known from other programming languages as well.

I could also use a TCP socket on localhost. What would be the benefits of using an IPC socket?

I used MemoryBlocks to generate hashes from files, if I remember correctly. And by void type, you mean that I can put any type of data in a MemoryBlock, correct?
And what do you mean by control structure? If/Else, For, While? Would you explain this?

So let’s say, I have created an event definition called ‘startFlying’ inside a class named ‘Bee’ and I have a class method ‘wasteEnergy()’, I could use AddHandler startFlying, AddressOf wasteEnergy. And inside my constructor(), I would call RaiseEvent startFlying. At the end, wasteEnergy() method will be executed and it would be possible to receive an object from the Bee class which is passed as a parameter from our wasteEnergy() method. Am I right?

On Windows, this is exactly what you’ll get. On Unix operating systems, IPCSocket uses unix domain sockets.

1 Like

A Xojo Thread is more generally known as a fibre. A fibre may appear asynchronous but truly is not. Whether that is of any concern would depend on the problem being solved. Some problems will be easier to solve by sharing a thread scheduled by the Xojo framework - A Xojo Thread. Other problems will be easier to solve using a dedicated thread scheduled by the operating system - a thread.

Not really. To my mind a microservice is an atomic server side process that responds to requests from one or more applications. What I described is a homogenous client side application that utilises two independant threads.

Talking about Xojo on Windows specifically, probably not many. I guess not having to manage port numbers could be a benefit.

A void type has no type. Type declaration is an abstraction imposed by the compiler. Sometimes it’s useful to dispose of the type imposition and operate on the bytes directly - The type has become void. The concept of void is perhaps more pertinent within languages that allow direct pointer manipulation.

A void type is an arbitrary number of bytes located at contiguous memory addresses. A memory block is an arbitrary number of bytes located at contiguous memory addresses. You can put any type of data in a memory block because all types are a number of bytes located at contiguous memory addresses.

I mean a structure that is used for control. Were you to remove all the methods from a class what you are left with is a structure. The data without the logic.

You could do that but the indirection does not achieve anything - You can just call wasteEnergy from the Constructor. A more interesting example could involve flySlowly and flyQuickly methods that are dynamically hooked by AddHandler to the startFlying event definition. Subsequently, when RaiseEvent startFlying is called, your Bee behaves differently depending on the funciton hooked to the event.

1 Like