From 3147a8399b601e251b8a3ba2947a35616c31077f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 30 May 2016 08:57:08 +0000 Subject: [PATCH] =?UTF-8?q?TestEIn=201.6r7=20:=20-=20modifiche=20per=20usc?= =?UTF-8?q?ire=20dal=20programma=20in=20modo=20sicuro=20mentre=20uno=20scr?= =?UTF-8?q?ipt=20=C3=A8=20in=20esecuzione.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Form1.vb | 27 ++++++++++++++++++++------- My Project/AssemblyInfo.vb | 4 ++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Form1.vb b/Form1.vb index 7fd2ff5..a19e1ff 100644 --- a/Form1.vb +++ b/Form1.vb @@ -40,7 +40,8 @@ Public Class Form1 Private WithEvents m_Controller As New Controller Private m_MruFiles As New MruList Private m_MruScripts As New MruList - Private m_bStopExec As Boolean = False + Private m_bScriptRunning As Boolean = False + Private m_bStopScript As Boolean = False Private m_ProcEventsCallback As New ProcessEventsCallback(AddressOf ProcessEvents) Private m_OutTextCallback As New OutTextCallback(AddressOf OutText) @@ -395,7 +396,13 @@ Public Class Form1 End Sub Private Sub Form1_FormClosing(sender As System.Object, e As FormClosingEventArgs) Handles MyBase.FormClosing - ' gestisco eventuale file corrente modificato + ' Impedisco uscita se script in esecuzione + If m_bScriptRunning Then + m_bStopScript = True + e.Cancel = True + Return + End If + ' Gestisco eventuale file corrente modificato If Not m_Controller.ManageModified() Then e.Cancel = True Return @@ -573,12 +580,15 @@ Public Class Form1 Private Sub OnExecutingScript(ByVal sender As Object) Handles m_Controller.OnExecutingScript ClearObjTree() ' Abilito progress e bottone stop - m_bStopExec = False - tsStatusStop.Enabled = True tsStatusProgress.Value = 0 + tsStatusStop.Enabled = True + m_bStopScript = False + ' Dichiaro script in esecuzione + m_bScriptRunning = True End Sub Private Sub OnExecutedScript(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean, ByVal sError As String) Handles m_Controller.OnExecutedScript + ' Salvo path dello script in lista recenti WritePrivateProfileString(S_GENERAL, K_LASTLUADIR, Path.GetDirectoryName(sFile), m_sIniFile) If bOk Then m_MruScripts.Add(sFile) @@ -587,8 +597,10 @@ Public Class Form1 MessageBox.Show(sError, EgtMsg(10001), MessageBoxButtons.OK, MessageBoxIcon.Error) ' Error End If ' Disabilito progress e bottone stop - tsStatusStop.Enabled = False tsStatusProgress.Value = 0 + tsStatusStop.Enabled = False + ' Dichiaro terminata esecuzione script + m_bScriptRunning = False End Sub Private Sub OnPrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String, @@ -796,7 +808,8 @@ Public Class Form1 ' Eventuale attesa Thread.Sleep(nPause) ' Ritorno eventuale stop - If m_bStopExec Then + If m_bStopScript Then + m_bStopScript = False Return 0 Else Return 1 @@ -1863,7 +1876,7 @@ Public Class Form1 End Sub Private Sub ToolStripStatusStop_Click() Handles tsStatusStop.Click - m_bStopExec = True + m_bStopScript = True End Sub diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 8f86759..f10a931 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -46,5 +46,5 @@ Imports System.Runtime.InteropServices ' utilizzando l'asterisco (*) come descritto di seguito: ' - - + +