Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Stopping BackGround worker Component In VB.net

Ahmed_A_2
Beginner
2,730 Views

Hi

I'm  dveloping VB.net program , where I'm using backgroundWorker component to have anther thread. To start the thread I used 

  BackgroundWorkerRun.RunWorkerAsync()  ,and to pend this thread I used

BackgroundWorkerRun.WorkerSupportsCancellation = True
BackgroundWorkerRun.CancelAsync()

But The main problem that I have is how to Stop this thread , Could you please help me to solve this problem and It will be appreciated if you provid me with some example for how to stop BackgroungWorker 

Many thanks

Ahmed

 

   

0 Kudos
8 Replies
SergeyKostrov
Valued Contributor II
2,730 Views
Try to use public method Dispose ( it could be overloaded ) and it should release all resources used by the component.
0 Kudos
Ahmed_A_2
Beginner
2,730 Views

I will be do appreciate if you explain more to to use method Dispose

many thanks

Ahmed

0 Kudos
SergeyKostrov
Valued Contributor II
2,730 Views
Ahmed, This is simply to note that you've asked the question on Intel Visual Fortran Compiler for Windows forum. Do you have access to MSDN ( local or on the Internet )? Or, please try to ask all questions related to VB .NET programming on social.msdn.microsoft.com/Forums website.
0 Kudos
Ahmed_A_2
Beginner
2,730 Views

Oh , you are right. I have already did that 

many thanks

0 Kudos
Ahmed_A_2
Beginner
2,730 Views

Hi 

I have solved the problem of controlling the thread as I mentioned before.But I'm facing anther problem with Fortran DLL file I'm using.While I can run , pause , and stop the thread that call the Fortran Dll file ,but I can not run anther model where  the calling to the subroutine from VB.net exist in the  DLL file done onece and when the simulation done and the function return to the main call I will not be able to call this subroutine again untill I close the whole interface. Could you please help me what are the sources of such problem , as I don't have to close the interface inorder to run anther program(It seems to me the dll file is busy by something although the simulation is done)

this is the fortran subroutine I'm using

Subroutine FortranDLL(A,IA)
!MS$ATTRIBUTES DLLEXPORT, ALIAS: 'FORTRANDLL' :: FortranDLL
IMPLICIT REAL*8 (A-H,O-Z)
DIMENSION A(5000001),IA(5000001)
OPEN(unit=1000,file=
+'C:\Sams2000\Applications\ATTIF2000\Engine\AttifSavedResults.txt')
CALL ATIFLO00(A,IA)
CLOSE (1000)
Return
End Subroutine FortranDLL

and this is the decleration and the call in VB.net 

Declare Sub FortranDLL Lib "C:\Sams2000\Applications\ATTIF2000\Engine\ATTIFDLLENG.dll" Alias "FORTRANDLL" (<[In](), Out()> ByVal A() As Double, ByVal IA() As Int32)

Private Sub BackgroundWorkerRun_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorkerRun.DoWork
FortranDLL(A, IA)
MsgBox("Simulation Done.")
End Sub

Your help is all the time important

Many thanks

Ahmed

 

0 Kudos
SergeyKostrov
Valued Contributor II
2,730 Views
>>...when the simulation done and the function return to the main call I will not be able to call this subroutine again >>untill I close the whole interface... Here is a generic question: What happens if you call FortranDLL function again, like: ... FortranDLL( A, IA ) MsgBox("Simulation Done - 1") FortranDLL( A, IA ) MsgBox("Simulation Done - 2") ... Is there an error message, or exception, or the application crash?
0 Kudos
Ahmed_A_2
Beginner
2,730 Views

Hi

I have already done that before and , I did it again as you asked right now. After it is done with the first call of FortranDLL( A, IA ), amessage MsgBox("Simulation Done - 1") appears, and then the interface closed/crashed at the second call of  FortranDLL( A, IA ), without any error messages but it is clear it is because the second call

Your help will be appreciated.

Ahmed

0 Kudos
SergeyKostrov
Valued Contributor II
2,730 Views
>>...After it is done with the first call of FortranDLL( A, IA ), amessage MsgBox("Simulation Done - 1") appears, and then the interface >>closed/crashed at the second call of FortranDLL( A, IA )... In order to understand what is wrong you could use a very simple technique and simply use a call to a MessageBox function to trace when a problem happens, like: ...FortranFunction( ... )... BEGIN ... // some processing 1 MessageBox( "Step 1" ) ... // some processing 2 MessageBox( "Step 2" ) ... // some processing 3 MessageBox( "Step 3" ) ... // some processing 4 MessageBox( "Step 4" ) ... END
0 Kudos
Reply