Form running on worker thread and not main thread

Form running on worker thread and not main thread - 消息

#1 已发布: 2023/5/27 18:26:25
muiz

muiz

15个赞,共22个帖子。

组: 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 已发布: 2023/5/27 18:50:48
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: 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位用户喜欢此帖子
muiz 2023/5/28 17:36:00
  • 有新帖
  • 无新帖