MicroStation hanging at "LINESTYLE IMPORT TODGN" key-in

Hi All,

I have a process where by I flush the line style cache of the active file and then reload the linestyles from our linestyle rsc files.
This removes any definitions that have been overwritten and ensures that the definitions in the active file are the same as the definitions in our current line style library. 

//Scan through file and remove and delete any linestyles from our resource files from the linestyle cache 
StringList* pLineStyles;
pLineStyles = (StringList*)mdlLineStyle_nameGetStringList(NULL, LSSL_OPT_RSCONLY);
long lStyleCount = mdlStringList_size(pLineStyles);
for (int i=0; i < lStyleCount; i++)
{

char* pString;
mdlStringList_getMember(&pString, NULL, pLineStyles, i);

LineStyleNameInfo sLineStyleInfo;
mdlLineStyle_nameQuery (&sLineStyleInfo, pString, mdlModelRef_getActive(), 0);

int status = 0;
status = mdlLineStyle_cacheDelete (sLineStyleInfo.rscFile, sLineStyleInfo.rscType, sLineStyleInfo.rscID, 0);

}

//Re-import all our custom linestyles into the current file
mdlInput_sendSynchronizedKeyin ("LINESTYLE IMPORT TODGN ALL \"C:\\ProgramData\\Bentley\\MicroStation V8i (SELECTseries)\\WorkSpace\\Projects\\VicRoads_LVNames\\symb\\vr_lines_v8.rsc\"", FALSE, 0, NULL);
mdlInput_sendSynchronizedKeyin ("LINESTYLE IMPORT TODGN ALL \"C:\\ProgramData\\Bentley\\MicroStation V8i (SELECTseries)\\WorkSpace\\Projects\\VicRoads_LVNames\\symb\\vr_lmark_v8.rsc\"", FALSE, 0, NULL);

Most of the time this works quite well. Occasionally, my program will hang for a minute or more at the line shown in bold while MicroStation processes the command. Very occasionally it crashes MicroStation.

The reason I send a "Synchronized" keyin is because I do some further processing of lines later in the program (setting scales, etc.) and I want to make sure MicroStation has finished replacing the linestyle definitions.

I have previously attempted to re-import our custom linestyles using the mdlResource_... commands without much luck.

Does anyone have any suggestions as to how to avoid MicroStation hanging\crashing at the line above.? (Either using mdlResource_.. functions or otherwise).

Thanks
Liam