Borrar filtros
Borrar filtros

system file watch crash

2 visualizaciones (últimos 30 días)
AA
AA el 26 de En. de 2015
Respondida: Guillaume el 26 de En. de 2015
fsw = System.IO.FileSystemWatcher();
fsw.Path = 'C:\Users\wolfgang\Desktop';
fsw.Filter = 'NZDUSD1.csv';
fsw.EnableRaisingEvents = true;
listenerhandle = addlistener(fsw, 'Changed', @(~,~)importfcn(q,a));
%signature of importfcn is function importfcn(sender, eventargs)
%add a small delay in importfcn before reading the file as the event is raised
%to make sure that file modification is complete
When I run this file, .csv file gets imported every minute and then processed. Sometimes, the imported file is still processed and the next import is delayed. This leads to the delay of several files.
In the end my matlab crashed and I get an error message. How can I resolve this problem?
  2 comentarios
Guillaume
Guillaume el 26 de En. de 2015
What is the error message?
AA
AA el 26 de En. de 2015
Editada: Star Strider el 26 de En. de 2015
------------------------------------------------------------------------
Unknown exception 0xe0434352 detected at Sun Jan 25 23:40:23 2015
------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled
Default Encoding : windows-1252
MATLAB Architecture: win64
MATLAB Root : C:\Program Files\MATLAB\R2014a
MATLAB Version : 8.3.0.532 (R2014a)
Operating System : Microsoft Windows 7 Home Premium
Processor ID : x86 Family 6 Model 60 Stepping 3, GenuineIntel
Virtual Machine : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : Version 6.1 (Build 7601: Service Pack 1)
Fault Count: 1
Abnormal termination:
Unknown exception 0xe0434352
Register State (from fault):
RAX = 00000006c5c7ffbf RBX = 0000000000000001
RCX = 00000006b3ffe180 RDX = 0000000000000128
RSP = 00000006b3ffe790 RBP = 00000000000f8087
RSI = 00000006b3ffe8f8 RDI = 0000000000000005
R8 = 0000000000000000 R9 = 0000000000000000
R10 = 0000000000000000 R11 = 00000006b3ffe7d0
R12 = 0000000000004000 R13 = 0000000000000001
R14 = 00000000e0434352 R15 = 00000000000f8087
RIP = 000007fefcf3940d EFL = 00000202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x000007fefcf3940d C:\Windows\system32\KERNELBASE.dll+00037901 RaiseException+00000061
[ 1] 0x000007fef5955294 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll+01397396 CopyPDBs+00039552
[ 2] 0x000007fef595508e C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll+01396878 CopyPDBs+00039034
[ 3] 0x000007feec39d54d C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\701f2b79b02a02beba70e50bb2edb212\mscorlib.ni.dll+20632909
[ 4] 0x000007fe96314a60 <unknown-module>+00000000
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help.

Iniciar sesión para comentar.

Respuesta aceptada

Guillaume
Guillaume el 26 de En. de 2015
Where do the q and a come from in your anonymous function?
As there is no point detecting file modifications while you're already processing them, I would disable the FileSystemWatcher at the beginning of importfcn and reenable it at the end. You could also check for modification right at the end of the function and process again if it has. Something like:
function importfcn(sender, eventargs)
sender.EnableRaisingEvents = false; %disable filesystemwatcher
%wait a little while to make sure modifications are complete
fpath = fullfike(sender.Path, sender.Filter);
oldmtime = System.IO.File.GetLastWriteTime(fpath);
while true
%process file
newmtime = System.IO.File.GetLastWriteTime(fpath);
if oldmtime.Equals(newmtime)
break %file hasn't changed. break out of loop
end
end
sender.EnableRaisingEvents = true;
end
warning: completely untested code. May contain bugs.

Más respuestas (0)

Categorías

Más información sobre Call Java from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by