hexagon logo

Automation Issue with .NET

When opening and executing PC-DMIS programs from a Windows VB.Net application, on SOME machines SOME of the time, the main PC-DMIS window will not display.
Only the PC-DMIS Execution Window is displayed - PC-DMIS User Prompts are essentially unavailable. In this case, closing PC-DMIS via task manager is the only solution.

My open and Execute construct are (essentially) the following:

PCDMISapplication = New PCDLRN.Application
PCDprograms = PCDMISapplication.PartPrograms
PCDMISapplication.Visible = True
PCDpartPrg = PCDMISprograms.Open(pathAndFilename, machineName)
Threading.Thread.Sleep(2000) ' Wait while program opens
PCDMISapplication.WaitUntilReady(200)
PCDpartPrg.Visible = True
PCDpartPrg.EXECUTE()


I suspect the solution is to add a variable the Thread.Sleep() and WaitUntilReady() methods and increase the times until this stops. But that doesn't explain the random nature.

Another Thought: Since I'm also handling some PartProgram Object events, I'm tempted to put the PCDpartPrg.Visible = True in a regularly fired event. But this seems like wikkid overkill. Again, I'd just like to understand the nature of this random problem.

Any thoughts?

Thanks,
Dan (in DFW - supposedly)
Parents
  • I had issues with pc-dmis coming to the front (it was visible, just behind my main form)

    This was usually just in the first instance, after I'd given it the focus (by clicking on it in the task bar) it would be shown and hidden as programmed to.

    It wasn't always either. I tried all manor of showing/hiding and SetActive with no joy. Offline it always worked, online it was hit and miss.


    In the end I used this method to make it reliably come to the front.


            Dim prc As Process = Process.GetProcessesByName("PCDLRN").FirstOrDefault
            Dim element As AutomationElement = AutomationElement.FromHandle(prc.MainWindowHandle)
            If Not element Is Nothing Then
                element.SetFocus()
            End If
    
    
Reply
  • I had issues with pc-dmis coming to the front (it was visible, just behind my main form)

    This was usually just in the first instance, after I'd given it the focus (by clicking on it in the task bar) it would be shown and hidden as programmed to.

    It wasn't always either. I tried all manor of showing/hiding and SetActive with no joy. Offline it always worked, online it was hit and miss.


    In the end I used this method to make it reliably come to the front.


            Dim prc As Process = Process.GetProcessesByName("PCDLRN").FirstOrDefault
            Dim element As AutomationElement = AutomationElement.FromHandle(prc.MainWindowHandle)
            If Not element Is Nothing Then
                element.SetFocus()
            End If
    
    
Children
No Data