Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Catch RaiseException in VB.Net

jmdelfa
Beginner
593 Views
Hi.
I've a VB.NET application (app1) which calls another program writen in Fortran (app2).
Summarizing, I want to catch an app1 the exception raised by app2 through RaiseException.

app1 launch app2 like a process into a thread: using the .NET "Process" class. Here is the code (summarized):

'-----------------VB application-----------------'
Private ThreadFor As New Thread(AddressOf LaunchProcess)
ThreadFor.Start()

Private Sub LaunchProcess()
Dim Proc As Process
Proc = New Process
Proc.StartInfo.FileName = "C:FortranApplication.exe"
Proc.StartInfo.WorkingDirectory = "C:"
'Here goes the Option1 or Option2 code (see below)
End Sub
'---------------END VB application---------------'

When app2 reaches one point (p1), app1 is notified and it will pause app2 execution. app1 then takes the control until the user orders to continue with app2 at the point it was paused. The code I've tried for app2 is the following:

'-----------------VF application-----------------'
program SIGNALSENDEREXE
implicit none

!DEC$IF DEFINED (_DLL)
use DFWIN, only: RaiseException, NULL
integer, parameter:: MyException = Z"AC1DBABE"

write(*,*) 'Before pause point p1'
call RaiseException(MyException,0,0,NULL)
write(*,*) 'After pause point p1'
!DEC$ENDIF
end program SIGNALSENDEREXE
'---------------END VF application---------------'

The problem is that app1 doesn't realize about the exception raised by app2. I've tried two options to catch the RaiseException:

'------------------Option1------------'
Try
Proc.Start()
Catch ex As Exception
'VB Code after RaiseException
End Try

'------------------Option2------------'
On Error GoTo Handler
Proc.Start()
Proc.WaitForExit()
Exit Sub
Handler:
'VB Code after RaiseException

In both Options, the program never enter into the error handleing section.

Any idea???
0 Kudos
0 Replies
Reply