Form running on worker thread and not main thread

Form running on worker thread and not main thread - Messages

#1 Posted: 5/27/2023 6:26:25 PM
muiz

muiz

15 likes in 22 posts.

Group: User

Hello everyone,

I am currently working on the maxima plugin (bug fixing etc.). One of the bugs I'm currently focusing on involves locating the Maxima executables within the plugin. In the plugin there is a form that allows users to search for the Maxima folder when the maxima executable is not found, but I have encountered an unexpected behavior during testing. For users who have freshly installed the plugin and try to execute any Maxima command, the form appears automatically for less than a second and then automatically closes. This indicates that the form is running on a different thread, separate from the main thread (from my understanding and testing using debugger).

Is it possible to access the main thread (the UI thread) in SMath? Maybe something like
Thread.Join()[/code] but I am not sure if that is an option for this case. I am relatively new to this project therefore I'm seeking some guidance and examples on how to achieve this.

Currently, the code responsible for executing the form is as follows:

[code=csharp]public void foundNoPath()
{
    if (SharedFunctions.initializingOverMenue) return;

    DialogResult result2 = MessageBox.Show(
        "Cannot find maxima.bat. Do you want to enter a start search path now?",
        "Cannot find maxima.bat", 
        MessageBoxButtons.YesNo, 
        MessageBoxIcon.Information, 
        MessageBoxDefaultButton.Button1,
        MessageBoxOptions.ServiceNotification);
    if (result2 == DialogResult.Yes)
    {
        //this is where the mentioned form is executed
        MForms.SettingsForm sf = new MForms.SettingsForm();
        sf.Show();
    }
}

Please note that this code is only executed when initiating a new Maxima session, and according to my observations using the debugger, it appears to be executed by one of the worker threads instead of the main thread.

I would greatly appreciate it if anyone could provide me with examples or suggestions. Thank you all in advance for your support and assistance.

Regards,
#2 Posted: 5/27/2023 6:50:48 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Hello,

I' m not sure if it is the same issue but I guess you can try with the save dialog approach for XeLaTeX documents, code is here, starting from line 99.

feel free to ask if you need further help and thank you for your efforts to improve this plugin .
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
muiz 5/28/2023 5:36:00 PM
  • New Posts New Posts
  • No New Posts No New Posts