Hi i have created a program to collect data from many sensors (video capture, audio capture and sensor data like GPS, Speed etc), the data is saved to a temoporary directory depending on the minute if the minute is odd then it would be saved to something like 'D:\Temp\Odd' and if the current minute is even then the data is saved to the 'D:\Temp\Even'. then at 15 seconds past the minute the data in the directory not currently being saved to is compressed and backed up, then the files deleted. so if i am currently saving data to the 'D:\Temp\Even' directory then the data in the 'D:\Temp\Odd' directory will be backed up and the temp files deleted from the 'Odd' directory. so essentually in the backup locations you have lots of minute zip files saved in directories depending on date and hour.
This all works great and the operator can monitor the recorded data on screen, my problem is that every minute the data in the directory that is not currently being written too is compressed and backed up to 1, 2 or 3 locations, this all works fine, but during the compress and store the GUI freezes for upto 15 seconds.
Below is the FileSave class i use to do the compression and backing up of the data (this is the whole class just cut and pasted below), i compiled it into a DLL and then send the relevant data to the DLL before calling the 'Startcompress' function, the DLL then just continues doing its thing, i thought DLLs when called ran in a different thread so i didn't think this would happen, does anyone have any ideas how to stop the GUI freeze.
Any ideas how to get around the GUI freezing, the locations it saves to are a local RAID hard drive and up to 2 network locations, if it is just saving to the hard drive then there is no lag, so the problem seems to be saving to the network drives.
Thanks
Stu
This all works great and the operator can monitor the recorded data on screen, my problem is that every minute the data in the directory that is not currently being written too is compressed and backed up to 1, 2 or 3 locations, this all works fine, but during the compress and store the GUI freezes for upto 15 seconds.
Below is the FileSave class i use to do the compression and backing up of the data (this is the whole class just cut and pasted below), i compiled it into a DLL and then send the relevant data to the DLL before calling the 'Startcompress' function, the DLL then just continues doing its thing, i thought DLLs when called ran in a different thread so i didn't think this would happen, does anyone have any ideas how to stop the GUI freeze.
VB.NET:
[COLOR=blue][COLOR=blue]Imports[/COLOR] System.IO
[COLOR=blue]Imports[/COLOR] System.IO.Compression
[COLOR=blue]Imports[/COLOR] System.Windows.Forms
[COLOR=blue]Imports[/COLOR] System
[COLOR=blue]Imports[/COLOR] System.Diagnostics
[COLOR=blue]Imports[/COLOR] System.Reflection
<[COLOR=#2b91af]Serializable[/COLOR]()> [COLOR=blue]Structure[/COLOR] [COLOR=#2b91af]fileSettings[/COLOR]
[COLOR=blue]Public[/COLOR] Temporary [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Public[/COLOR] Local [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Public[/COLOR] Fixed [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Public[/COLOR] Float [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Structure[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Class[/COLOR] [COLOR=#2b91af]FileSave[/COLOR]
[COLOR=blue]Dim[/COLOR] fileLocations [COLOR=blue]As[/COLOR] [COLOR=#2b91af]fileSettings[/COLOR]
[COLOR=blue]Dim[/COLOR] SERIALnumber [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Dim[/COLOR] attribSet [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR] = [COLOR=blue]False[/COLOR]
[COLOR=blue]Dim[/COLOR] TempSizeRemain [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR]
[COLOR=blue]Dim[/COLOR] LocalSizeRemain [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR]
[COLOR=blue]Dim[/COLOR] FloatSizeRemain [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR]
[COLOR=blue]Dim[/COLOR] FixedSizeRemain [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR]
[COLOR=blue]Dim[/COLOR] [COLOR=blue]WithEvents[/COLOR] TimeCheck [COLOR=blue]As[/COLOR] [COLOR=blue]New[/COLOR] [COLOR=#2b91af]Timer[/COLOR]
[COLOR=blue]Dim[/COLOR] lastComp [COLOR=blue]As[/COLOR] [COLOR=blue]Date[/COLOR]
[COLOR=blue]Dim[/COLOR] startcomp [COLOR=blue]As[/COLOR] [COLOR=blue]Date[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Function[/COLOR] UpdateSettings([COLOR=blue]ByVal[/COLOR] SERnum [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] LocalLocation [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] FloatLocation [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] FixedLocation [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] TempLocation [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] TempSize [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR], [COLOR=blue]ByVal[/COLOR] LocSize [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR], [COLOR=blue]ByVal[/COLOR] FloatSize [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR], [COLOR=blue]ByVal[/COLOR] FixedSize [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]Try[/COLOR]
SERIALnumber = SERnum
fileLocations.Local = LocalLocation
fileLocations.Fixed = FixedLocation
fileLocations.Float = FloatLocation
fileLocations.Temporary = TempLocation
TempSizeRemain = TempSize
LocalSizeRemain = LocSize
FloatSizeRemain = FloatSize
FixedSizeRemain = FixedSize
lastComp = [COLOR=#2b91af]DateTime[/COLOR].Now
attribSet = [COLOR=blue]True[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
attribSet = [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]Return[/COLOR] attribSet
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Function[/COLOR] SetLastCompress([COLOR=blue]ByVal[/COLOR] LstComp [COLOR=blue]As[/COLOR] [COLOR=blue]Date[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]Dim[/COLOR] ret [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR] = [COLOR=blue]False[/COLOR]
[COLOR=blue]Try[/COLOR]
lastComp = LstComp
ret = [COLOR=blue]True[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
ret = [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]Return[/COLOR] ret
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Function[/COLOR] CompressFiles(TempFolderString [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]Dim[/COLOR] RETVals [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR] = [COLOR=blue]True[/COLOR]
[COLOR=blue]Try[/COLOR]
[COLOR=blue]Dim[/COLOR] D, F, LocalFname, FloatFname, FixedFname [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
D = Generate_Directory()
F = Generate_FileName([COLOR=#a31515]",Archive,"[/COLOR], [COLOR=#a31515]".zip"[/COLOR], 1)
[COLOR=green]'check if folder exists[/COLOR]
[COLOR=green]'add to archive list [/COLOR]
startcomp = [COLOR=#2b91af]DateTime[/COLOR].Now
[COLOR=green]'generate filename and locations[/COLOR]
LocalFname = fileLocations.Local & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
FloatFname = fileLocations.Float & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
FixedFname = fileLocations.Fixed & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
[COLOR=green]'check if directory exists if not then create it[/COLOR]
[COLOR=blue]If[/COLOR] [COLOR=blue]My[/COLOR].Computer.FileSystem.DirectoryExists(fileLocations.Local & [COLOR=#a31515]"\Archive\"[/COLOR] & D) = [COLOR=blue]False[/COLOR] [COLOR=blue]Then[/COLOR]
[COLOR=blue]My[/COLOR].Computer.FileSystem.CreateDirectory(fileLocations.Local & [COLOR=#a31515]"\Archive\"[/COLOR] & D)
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]If[/COLOR] [COLOR=#2b91af]File[/COLOR].Exists(LocalFname) [COLOR=blue]Then[/COLOR]
F = Generate_FileName([COLOR=#a31515]",Archive,"[/COLOR], [COLOR=#a31515]".zip"[/COLOR], 0)
LocalFname = fileLocations.Local & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
FloatFname = fileLocations.Float & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
FixedFname = fileLocations.Fixed & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
[COLOR=blue]If[/COLOR] [COLOR=#2b91af]File[/COLOR].Exists(LocalFname) [COLOR=blue]Then[/COLOR]
F = Generate_FileName([COLOR=#a31515]",Archive,"[/COLOR], [COLOR=#a31515]".zip"[/COLOR], 0 - 1)
LocalFname = fileLocations.Local & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
FloatFname = fileLocations.Float & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
FixedFname = fileLocations.Fixed & [COLOR=#a31515]"\Archive\"[/COLOR] & D & [COLOR=#a31515]"\"[/COLOR] & F
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=green]'compress the temporary files[/COLOR]
[COLOR=blue]If[/COLOR] Compress_Files(TempFolderString, LocalFname) = [COLOR=blue]False[/COLOR] [COLOR=blue]Then[/COLOR]
Housekeeping(fileLocations.Local)
Housekeeping(fileLocations.Fixed)
Housekeeping(fileLocations.Float)
[COLOR=blue]If[/COLOR] Compress_Files(TempFolderString, LocalFname) = [COLOR=blue]False[/COLOR] [COLOR=blue]Then[/COLOR] RETVals = [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]If[/COLOR] RETVals = [COLOR=blue]True[/COLOR] [COLOR=blue]Then[/COLOR]
[COLOR=green]'copy the file[/COLOR]
[COLOR=blue]If[/COLOR] Copy_Files(LocalFname, FloatFname) = [COLOR=blue]False[/COLOR] [COLOR=blue]Then[/COLOR]
Housekeeping(fileLocations.Local)
Housekeeping(fileLocations.Fixed)
Housekeeping(fileLocations.Float)
Copy_Files(LocalFname, FloatFname)
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]If[/COLOR] Copy_Files(LocalFname, FixedFname) = [COLOR=blue]False[/COLOR] [COLOR=blue]Then[/COLOR]
Housekeeping(fileLocations.Local)
Housekeeping(fileLocations.Fixed)
Housekeeping(fileLocations.Float)
Copy_Files(LocalFname, FixedFname)
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=green]'delete the temporary files[/COLOR]
[COLOR=blue]Dim[/COLOR] DirFiles [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]() = System.IO.[COLOR=#2b91af]Directory[/COLOR].GetFiles(fileLocations.Temporary & TempFolderString)
[COLOR=blue]Dim[/COLOR] A [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int16[/COLOR]
[COLOR=blue]For[/COLOR] A = 0 [COLOR=blue]To[/COLOR] DirFiles.GetUpperBound(0)
System.IO.[COLOR=#2b91af]File[/COLOR].Delete(DirFiles(A))
[COLOR=blue]Next[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]Dim[/COLOR] retval [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
retval = Housekeeping(fileLocations.Local)
retval = Housekeeping(fileLocations.Fixed)
retval = Housekeeping(fileLocations.Float)
[COLOR=blue]Return[/COLOR] RETVals
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
startcomp = [COLOR=#2b91af]DateTime[/COLOR].Now.AddMinutes(-2)
[COLOR=blue]Return[/COLOR] [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Private[/COLOR] [COLOR=blue]Function[/COLOR] Compress_Files([COLOR=blue]ByVal[/COLOR] TempFolderString [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] LocalFname [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]Dim[/COLOR] ret [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR] = [COLOR=blue]False[/COLOR]
[COLOR=blue]Dim[/COLOR] sf [COLOR=blue]As[/COLOR] [COLOR=#2b91af]StackFrame[/COLOR] = [COLOR=blue]New[/COLOR] [COLOR=#2b91af]StackFrame[/COLOR]()
[COLOR=blue]Dim[/COLOR] mb [COLOR=blue]As[/COLOR] [COLOR=#2b91af]MethodBase[/COLOR] = sf.GetMethod()
[COLOR=blue]Try[/COLOR]
[COLOR=green]'compress the temporary files[/COLOR]
[COLOR=#2b91af]ZipFile[/COLOR].CreateFromDirectory(fileLocations.Temporary & TempFolderString, LocalFname, [COLOR=#2b91af]CompressionLevel[/COLOR].Optimal, [COLOR=blue]False[/COLOR])
ret = [COLOR=blue]True[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
[COLOR=blue]Dim[/COLOR] sw [COLOR=blue]As[/COLOR] System.IO.[COLOR=#2b91af]StreamWriter[/COLOR]
[COLOR=blue]If[/COLOR] System.IO.[COLOR=#2b91af]File[/COLOR].Exists([COLOR=#a31515]"D:\Error.txt"[/COLOR]) [COLOR=blue]Then[/COLOR]
System.IO.[COLOR=#2b91af]File[/COLOR].Delete([COLOR=#a31515]"D:\Error.txt"[/COLOR])
sw = [COLOR=blue]My[/COLOR].Computer.FileSystem.OpenTextFileWriter([COLOR=#a31515]"D:\Error.txt"[/COLOR], [COLOR=blue]False[/COLOR])
sw.WriteLine(ex.Message)
sw.Close()
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
ret = [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]Return[/COLOR] ret
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Private[/COLOR] [COLOR=blue]Function[/COLOR] Copy_Files([COLOR=blue]ByVal[/COLOR] LocalFname [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] cFname [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]Dim[/COLOR] ret [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR] = [COLOR=blue]False[/COLOR]
[COLOR=blue]Try[/COLOR]
[COLOR=blue]My[/COLOR].Computer.FileSystem.CopyFile(LocalFname, cFname)
ret = [COLOR=blue]True[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
ret = [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]Return[/COLOR] ret
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Private[/COLOR] [COLOR=blue]Function[/COLOR] Generate_Directory() [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Dim[/COLOR] fname [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Dim[/COLOR] Nows [COLOR=blue]As[/COLOR] [COLOR=blue]Date[/COLOR] = [COLOR=#2b91af]DateTime[/COLOR].Now.AddMinutes(-1)
[COLOR=blue]Dim[/COLOR] startTargetDate [COLOR=blue]As[/COLOR] [COLOR=blue]New[/COLOR] [COLOR=#2b91af]DateTime[/COLOR](Nows.Year, Nows.Month, Nows.Day, Nows.Hour, 0, 0)
[COLOR=blue]Dim[/COLOR] format [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] = [COLOR=#a31515]"yyyyMMdd-HHmm"[/COLOR]
fname = startTargetDate.ToString(format)
[COLOR=blue]Return[/COLOR] fname.Replace([COLOR=#a31515]"-"[/COLOR], [COLOR=#a31515]"\"[/COLOR])
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Private[/COLOR] [COLOR=blue]Function[/COLOR] Generate_FileName([COLOR=blue]ByVal[/COLOR] fType [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] Exten [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], [COLOR=blue]ByVal[/COLOR] takeMins [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int16[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Dim[/COLOR] fname [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
[COLOR=blue]Dim[/COLOR] Nows [COLOR=blue]As[/COLOR] [COLOR=blue]Date[/COLOR] = [COLOR=#2b91af]DateTime[/COLOR].Now.AddMinutes(-takeMins)
[COLOR=blue]Dim[/COLOR] startTargetDate [COLOR=blue]As[/COLOR] [COLOR=blue]New[/COLOR] [COLOR=#2b91af]DateTime[/COLOR](Nows.Year, Nows.Month, Nows.Day, Nows.Hour, Nows.Minute, 0)
[COLOR=blue]Dim[/COLOR] format [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] = [COLOR=#a31515]"yyMMdd,HHmmss"[/COLOR]
fname = startTargetDate.ToString(format) & fType & SERIALnumber & Exten
[COLOR=blue]Return[/COLOR] fname
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Private[/COLOR] [COLOR=blue]Function[/COLOR] Housekeeping(fileLocation [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR])
[COLOR=blue]Try[/COLOR]
[COLOR=blue]Dim[/COLOR] lookForSize [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Int32[/COLOR]
[COLOR=blue]Dim[/COLOR] LocationString [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] = [COLOR=#a31515]""[/COLOR]
[COLOR=blue]Dim[/COLOR] deleteNeeded [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR] = [COLOR=blue]False[/COLOR]
[COLOR=blue]Select[/COLOR] [COLOR=blue]Case[/COLOR] fileLocation
[COLOR=blue]Case[/COLOR] fileLocations.Temporary
lookForSize = TempSizeRemain
LocationString = fileLocations.Temporary
[COLOR=blue]Case[/COLOR] fileLocations.Local
lookForSize = LocalSizeRemain
LocationString = fileLocations.Local
[COLOR=blue]Case[/COLOR] fileLocations.Float
lookForSize = FloatSizeRemain
LocationString = fileLocations.Float
[COLOR=blue]Case[/COLOR] fileLocations.Fixed
lookForSize = FixedSizeRemain
LocationString = fileLocations.Fixed
[COLOR=blue]Case Else[/COLOR]
lookForSize = 0
[COLOR=blue]End[/COLOR] [COLOR=blue]Select[/COLOR]
[COLOR=green]'Check if the dive has more space than the value set in the INI file[/COLOR]
[COLOR=blue]If[/COLOR] lookForSize <> 0 [COLOR=blue]Then[/COLOR]
[COLOR=blue]Dim[/COLOR] Drives() [COLOR=blue]As[/COLOR] [COLOR=#2b91af]DriveInfo[/COLOR] = [COLOR=#2b91af]DriveInfo[/COLOR].GetDrives()
[COLOR=blue]For[/COLOR] [COLOR=blue]Each[/COLOR] drive [COLOR=blue]As[/COLOR] [COLOR=#2b91af]DriveInfo[/COLOR] [COLOR=blue]In[/COLOR] Drives
[COLOR=blue]If[/COLOR] drive.Name = fileLocation.Substring(0, 3) [COLOR=blue]Then[/COLOR]
[COLOR=#2b91af]Debug[/COLOR].Print(drive.TotalFreeSpace / 1024 / 1024)
[COLOR=blue]If[/COLOR] (drive.TotalFreeSpace / 1024 / 1024) < FixedSizeRemain [COLOR=blue]Then[/COLOR]
deleteNeeded = [COLOR=blue]True[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]Next[/COLOR]
[COLOR=green]'if the space is less than the value in the INI file then delete the oldest Folder[/COLOR]
[COLOR=blue]If[/COLOR] deleteNeeded = [COLOR=blue]True[/COLOR] [COLOR=blue]Then[/COLOR]
[COLOR=blue]Dim[/COLOR] DirPaths [COLOR=blue]As[/COLOR] Linq.[COLOR=#2b91af]IOrderedEnumerable[/COLOR]([COLOR=blue]Of[/COLOR] IO.[COLOR=#2b91af]DirectoryInfo[/COLOR]) = [COLOR=blue]New[/COLOR] [COLOR=#2b91af]DirectoryInfo[/COLOR](LocationString & [COLOR=#a31515]"\Archive\"[/COLOR]).GetDirectories().OrderBy([COLOR=blue]Function[/COLOR](c [COLOR=blue]As[/COLOR] [COLOR=#2b91af]DirectoryInfo[/COLOR]) c.CreationTime)
[COLOR=#2b91af]Directory[/COLOR].Delete(LocationString & [COLOR=#a31515]"\Archive\"[/COLOR] & DirPaths(0).Name, [COLOR=blue]True[/COLOR])
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]Return[/COLOR] [COLOR=blue]True[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
[COLOR=blue]Return[/COLOR] [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Sub[/COLOR] [COLOR=blue]New[/COLOR]()
TimeCheck.Interval = 1000
TimeCheck.Enabled = [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Function[/COLOR] GetLastComp()
[COLOR=blue]Return[/COLOR] lastComp
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Private[/COLOR] [COLOR=blue]Sub[/COLOR] TimeCheck_Tick(sender [COLOR=blue]As[/COLOR] [COLOR=blue]Object[/COLOR], e [COLOR=blue]As[/COLOR] [COLOR=#2b91af]EventArgs[/COLOR]) [COLOR=blue]Handles[/COLOR] TimeCheck.Tick
[COLOR=blue]Dim[/COLOR] sf [COLOR=blue]As[/COLOR] [COLOR=#2b91af]StackFrame[/COLOR] = [COLOR=blue]New[/COLOR] [COLOR=#2b91af]StackFrame[/COLOR]()
[COLOR=blue]Dim[/COLOR] mb [COLOR=blue]As[/COLOR] [COLOR=#2b91af]MethodBase[/COLOR] = sf.GetMethod()
[COLOR=blue]Try[/COLOR]
[COLOR=blue]Dim[/COLOR] dd [COLOR=blue]As[/COLOR] [COLOR=blue]Date[/COLOR] = [COLOR=#2b91af]DateTime[/COLOR].Now
[COLOR=blue]Dim[/COLOR] RetVal [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]If[/COLOR] lastComp.AddMinutes(1).Minute >= dd.Minute [COLOR=blue]And[/COLOR] dd.Second >= 15 [COLOR=blue]And[/COLOR] startcomp.Minute <> dd.Minute [COLOR=blue]Then[/COLOR]
[COLOR=green]' Compressed the finished files[/COLOR]
[COLOR=blue]If[/COLOR] [COLOR=#2b91af]DateTime[/COLOR].Now.Minute [COLOR=blue]Mod[/COLOR] 2 = 0 [COLOR=blue]Then[/COLOR]
RetVal = CompressFiles([COLOR=#a31515]"\Odd"[/COLOR])
[COLOR=blue]Else[/COLOR]
RetVal = CompressFiles([COLOR=#a31515]"\Even"[/COLOR])
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]Dim[/COLOR] da [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
da = dd.ToString([COLOR=#a31515]"HH:mm:15 yyy-MM-dd"[/COLOR])
[COLOR=blue]If[/COLOR] RetVal = [COLOR=blue]True[/COLOR] [COLOR=blue]Then[/COLOR] lastComp = [COLOR=#2b91af]DateTime[/COLOR].Parse(da)
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Function[/COLOR] Startcompress() [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]Try[/COLOR]
[COLOR=blue]If[/COLOR] attribSet = [COLOR=blue]True[/COLOR] [COLOR=blue]Then[/COLOR]
TimeCheck.Interval = 1000
TimeCheck.Enabled = [COLOR=blue]True[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]Return[/COLOR] TimeCheck.Enabled
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]Public[/COLOR] [COLOR=blue]Function[/COLOR] StopCompress() [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR]
[COLOR=blue]Try[/COLOR]
TimeCheck.Enabled = [COLOR=blue]False[/COLOR]
[COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Exception[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR]
[COLOR=blue]Return[/COLOR] TimeCheck.Enabled
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Class[/COLOR][/COLOR]
Any ideas how to get around the GUI freezing, the locations it saves to are a local RAID hard drive and up to 2 network locations, if it is just saving to the hard drive then there is no lag, so the problem seems to be saving to the network drives.
Thanks
Stu