web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to Access Forms Controls in Thread ?

(0) ShareShare
ReportReport
Posted on by 25

 Hi,

I need to create a thread that can access Form control object,which Thread is called from it.
( My thread will do work such as modified stringEdit.text in it's caller form... )

I had search for solution from many sources but nothing useful was found.Please give me some direction( or solution would be better).

I very much appreciate your help or input in this one.

Thanks,
Mai 

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,030 Super User 2025 Season 2 on at

    Hi Mai,

    Take a look at the form "SysDataSearchDaemonManager". This forms controls the thread of the data crawler. The status is  updated automatically.

    The method "daemonUpdate" contains the code for display the status. Within the thread the status is updated in a table. The "deamonUpdate" is continiously called with the setTimeOut function and reads the status and updates the stingedit again and again.

    regards,

    André

  • Bluetower Profile Picture
    25 on at

    Thank you very much for your useful advise, André.

    It is exactly what I want to do.

     

    Regards,

    Mai


  • Thomas Wilke Profile Picture
    150 on at

    Hi André,

     i think i don't understand this. the setTimeOut calls the method again and again. to update the form. can you explain how the thread is working can't find something.

    my problem where I need a thread is the following:
    I've code that opens a form - init - run - wait() thats fine if i run this as a user but when i try to execute this by code my code stops at the call of wait() - Do you know a way to get around this?

    Thanks and best regards
     Thomas

  • André Arnaud de Calavon Profile Picture
    301,030 Super User 2025 Season 2 on at

    Hi Thomas,

    I don't know what you are trying to develop right now. A form can be opend by x++ code, but you will need a client to display the form.

    A thread is a clientless (additional) session which is running without a user interface. So opening a form from a thread is impossible. But within a thread you can execute some x++ code, e.g. building a search index for the data crawler.

    Can you explain in detail what you want to develop? When should the form appear? Is it for one user or more? Run it at start of AX or when you are logged in a while? Maybe there is a solution for your needs.

     

    regards,

    André

  • Thomas Wilke Profile Picture
    150 on at

    Hi André,

    i'm trying to imitate user interaction with a form. It's just a try to automate some steps on the client gui (not in the background).
    Therefor I have a method that opens a form, clicks a button which should open another Form (by code). But the click on this button executes code that creates a formRun init, run and than wait. Cause all this is running on one client the wait stops everything.

    I just found the notify method on the FormRun Object which releases the hold on an object that has called a wait method. I think that this will work for me.

    thanks 
     Thomas

  • André Arnaud de Calavon Profile Picture
    301,030 Super User 2025 Season 2 on at

    Hi Thomas,

    There might be another solution called "AutoIt". It is a tool for automation and scripting tasks. Check out the site http://www.autoitscript.com/autoit3/ for more details.

    regards,

    André

  • Thomas Wilke Profile Picture
    150 on at

    Hi André,

     thanks for the tip, I've tried autoit already. It's a nice tool.

    regards,
     Thomas

  • Suggested answer
    Community Member Profile Picture
    on at

    So i know this is wicked old but i think i have a solution to updating form controls properties from a thread.

    so we know that a thread outputs a container, which can be read from a method on your form during your threads execution.

    1.) Set the outputparm in the thread to a "special" string of your choice. Be aware, the listener method in step two works on Time, not a specific call, so you must be smart and make sure that your special string is not 1 value in a large container since we will be reading the last value of the container.

    //... somewhere in your method called by thread.run, maybe in a loop? set your special string to be a "parameter" to pass.
    specialstring = "command1";
    OutputCont+=specialstring;
    _t.setoutputparm(outputcont);


    2.) Create in a form method that is called right after you call your thread.run to read the outputparm

    void ThreadListener()
    {
    boolean 	callback = true;
    int		conlenval;
    ;
    
    try
    {
        if (runthread.status() == 0)  //thread isnt running, throw internal exception then retry on the catch
        {
            throw exception::Internal;
        }
        if (RunThread.status() == 2)    //thread is completed
        {
            callback = false; 
        }
        if(RunThread.status() == 1) // thread is executing
        {
            ThreadCont = RunThread.getOutputParm(); //set ThreadCont as current outputparm of thread.
            conlenval = conlen(ThreadCont);
    	if(conpeek(ThreadCont, conlenval) == "command1")
    	{
    		element.whatever = whatever; //or call a method or do some stuff
    	}
            if (callback == true) // call back this method until the thread is done
            {
                this.setTimeOut(identifierstr(ThreadListener), 100, true); //change 100ms to suite your needs
            }
        }
    
    }
    catch (Exception::Internal)
    {
        retry;
    }
    
    }

    Ive used this to update progress bars on a form that processes large amounts of data in a long running loop. It keeps my form running without running into API ghosting .. in AX2009

    --Steepho


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans