Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

the LW not fast enough in displaying info

To all

 

I have a small code which does the following

 

theLW.WriteLine("-Creating dictionaries...")
  'create dico1
  'create dico2
theLW.WriteLine("--Done")

theLW.WriteLine("-Processing file...")
  'do something
theLW.WriteLine("-File processed...")

 

I was hoping that the info in the LW is "printed" as the program progresses to let the user know what is happening but all the messages are printed almost in a block. The steps create 'dico1' and create 'dico2' may take a few seconds and yet I do not get the sequence

Message 1 printed

Nothing is happening while the dictionaries are created

Message 2 printed

Does anyone know if there is a way of controlling the LW?

 

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
3 REPLIES

Re: the LW not fast enough in displaying info

Hi!

 

Perhaps you can solve your problem with some simple threading.

You can try to start a new thread which will write "Creating Dictionaries" in the LW

(or MessageBox) and wait for him to stop before you proceed with further commands.

First you need to import

Imports System.Threading

and you need a sub like this:

Sub writeLWStart()

MsgBox("Starting Dico")

End Sub

 

Now you can initiate and start a new thread with

Dim Thread1 As New System.Threading.Thread(AddressOf writeLWStart)

Thread1.Start() ' Starting new thread

Thread1.Join() ' Waiting until the thread is done

MsgBox("End") ' or creating you dicos ..

 

 

You can also terminate your thread manually with an additional sub, if neccessary.

Hope that helps!

 

Bye,

 

Flo

Solution
Solution
Accepted by topic author selex_ct
‎05-05-2016 04:23 AM

Re: the LW not fast enough in displaying info

@selex_ct,

 

Try NXOpen.UF.UFUi.UpdateListingWindow to flush the list window buffer.

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/ugopen_doc...

 

Rather than calling this after every theLW.WriteLine, I wrote a wrapper function:

 

    Sub logOutput(ByVal stringList As List(Of String))

        theLw.Open()

        For Each line As String In stringList
            theLw.WriteLine(line)
        Next line

        theUfSession.Ui.UpdateListingWindow()

    End Sub

Re: the LW not fast enough in displaying info

thanks to both Jimb and FlolScreen for the suggestions. Will have a look at both. in the meatime I have also tried the use of: ufs.Ui.SetPrompt and it could be a way around it. It's just less obvious to the user what his happening
When I process the file I am experimenting with something like
dPercProgress = Math.Round(100*(i/ListofFELabel.Count),1)
ufs.Ui.SetPrompt("% Progress: "& Cstr(dPercProgress))

Thanks
Regards
Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)