|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Setting up delay for function callHi,
I have function which creates two xml files,after creation these xml's, I am calling another function which reads these xml files. Now this function is causing exception becuase data has not been read from xml file and stored in using by other control. I am looking out for some workaround by which i can delay the calls for reading out these xml files. Thanks in advance Manoj You might try executing the delayed action through a seperate thread.
Example: Thread _ExceededThread; ThreadStart _ExceededThreadStart; private void startDelayedTaskProcess() { _ExceededThreadStart = new ThreadStart(DelayedTaskStarter); _ExceededThread = new Thread(_ExceededThreadStart); _ExceededThread.Start(); } private static void DelayedTaskStarter() { Thread.Sleep(20000); DoDelayedTasks(); } There might be a better way... but this is the only way I know of right now... Aryan wrote: Show quote > Hi, > I have function which creates two xml files,after creation these > xml's, I am calling another function which reads these xml files. Now > this function is causing exception becuase data has not been read from > xml file and stored in using by other control. I am looking out for > some workaround by which i can delay the calls for reading out these > xml files. > > Thanks in advance > Manoj Manoj,
One way would be to create the files asynchronously using a new thread. Doing so you can loop until the new thread which is creating the xml files has completed and then read the files only after it has completed. It would look something like this: Dim NewThread As Threading.Thread = New Threading.Thread(AddressOf CreateXMLFiles) NewThread.SetApartmentState(Threading.ApartmentState.STA) NewThread.Start() While NewThread.IsAlive '---Here you can continue other processing while you wait for the thread to finish or just wait. End While '---It is now safe to read xml files. And here is a multi-threading tutorial: http://www.startvbdotnet.com/threading/default.aspx Sincerely, -- S. Justin Gengo Web Developer / Programmer Free code library: http://www.aboutfortunate.com "Out of chaos comes order." Nietzsche Show quote "Aryan" <manoj241***@gmail.com> wrote in message news:1157977205.192092.239830@i42g2000cwa.googlegroups.com... > Hi, > I have function which creates two xml files,after creation these > xml's, I am calling another function which reads these xml files. Now > this function is causing exception becuase data has not been read from > xml file and stored in using by other control. I am looking out for > some workaround by which i can delay the calls for reading out these > xml files. > > Thanks in advance > Manoj > |
|||||||||||||||||||||||