I have a couple of module processes that usually screw up in data processing.
I can’t remember the term. You overwork the computer and it slips some by not doing somethings.
I need to slow it down. I assume I create a timer dynamically (by code).
I don’t see why I need addhandler and I also can’t get the code right.
Dim slTimr As Timer
slTimr = New Timer
Addhandler slTimr.Action, addressof slTimr_Action
slTimr.Period = 500
slTimr.Mode = Timer.ModeSingle
It sounds like you’ve created a race condition, i.e., process 2 completes before process 1 when it shouldn’t. My recommendation, without actually seeing your code, is to create a better workflow.
[quote=411917:@Arthur Gabhart]II don’t see why I need addhandler and I also can’t get the code right.
If you don’t add a handler, what code is gonna be executed when the timer expires? If you really want to have a timer, then suspend the process after setting the timer going, and resume it in the handler.
Or you could just sleep the process.
Or just follow Kem’s suggestion - think about what it is you want to happen.
Thanks for the word. Yes to Race Condition.
The problem is below is for a word dictionary.
A short summary of the racing code. This is a loop where methods inside don’t always get called.
The files are text files and all of the same data structure.
Each text file in its final condition is an array of classes. This is for easy manipulation as a single dimension array.
[code]For i = 0 to DFilListA.Ubound//An array of FolderItems
//Followed by a section that copies members of the array
If DFilListA(i).CopyFileTo (DFilListB(i))//An array of copy to locations
f = DFilListB(i)
//Followed by the section that gets missed or a method inside gets missed.
If f <> Nil And f.Exists Then
tPPth is the name of the file.
This method CnvtLoad Is a method that:
a. converts the file to an array.
b. removes a header
b. doesn't always happen.
CnvtLoad passes the array to another method called
CnvtPrfDctF( wholeFile, f, sf ).
Wholefile is the array, f the fileName and sf is name of the file in text.
a. Removes several end elements
b. Adds elements to the array. The elements are cross-references to files.
b. doesn't always happen
I have tried to break it up into methods and it works probably 95% of the time. Many times it works 100%
Suggestions on preventing race failures.
Recreate the FolderItem after the copy to update it’s “exists” status immediately.
f2 = new FolderItem( f2 )
if f2.Exists then...
I solved my problem. Not sure which did it, but it was mostly fine-tuning the process. I also had a careless mistake. I thought I could compare FolderItems, but you have compare it by such things as NativePath.