eye5600,
We would probably need to see a "Short But Complete" code snippet to see
how this is being done. If your code creates a thread in order to do the
Crystal thing,
you could call the Join method on it, provided it is set as a background
thread.
Peter

Signature
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
> I have a procedure that creates a file, then generates a log report via
> Crystal. If the user closes the form after the file is created and before the
> log appears, the form closes, but (it appears that) a thread creating the
> Crystal report continues to run. How do I get hold of the thread and close
> it, or alternatley, look to see if it's running so I can delay close of the
> form?
eye5600 - 20 Dec 2005 21:48 GMT
> We would probably need to see a "Short But Complete" code snippet to see
> how this is being done.
oRpt.SetDataSource(dsRpt) ;
crView.ReportSource = oRpt ;
I'm just displaying the report, but the it takes long enough to appear (~5
sec) that it's easy to forget it's comming, and close the form.
Pohihihi - 20 Dec 2005 22:32 GMT
I usually show a hourglass kind of thing, in my case my own form with a
clock and a moving icon, to give prompt to the users that something is
happening. Additionally I catch distroy and prompt users if they really want
to cancel action. Maybe you want to find a better way than this but usually
it works for my clients.
>> We would probably need to see a "Short But Complete" code snippet to see
>> how this is being done.
[quoted text clipped - 4 lines]
> I'm just displaying the report, but the it takes long enough to appear (~5
> sec) that it's easy to forget it's comming, and close the form.
Peter Bromberg [C# MVP] - 20 Dec 2005 23:43 GMT
Yes,
There is no separate thread to deal with here. You need to find out if there
is a return value from this method call which would let you not allow the
user to close the form until it has returned, or a timeout has occured. In
the meantime, you could have some visual indicator on the form that shows the
user it is working. An hourglass cursor as suggested is a good step.
Peter

Signature
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
> > We would probably need to see a "Short But Complete" code snippet to see
> > how this is being done.
[quoted text clipped - 4 lines]
> I'm just displaying the report, but the it takes long enough to appear (~5
> sec) that it's easy to forget it's comming, and close the form.
eye5600 - 21 Dec 2005 14:11 GMT
I need a tad more detail. If the user closes the form using the close box in
the upper right, is there any way to intercept it besides the close event? If
I put code in the close event to delay until the processing is complete, how
do I make the program delay until my flag changes?
> Yes,
> There is no separate thread to deal with here. You need to find out if there
[quoted text clipped - 3 lines]
> user it is working. An hourglass cursor as suggested is a good step.
> Peter
eye5600 - 21 Dec 2005 14:40 GMT
Creating the closing event for the form and setting e.Cancel to the
appropriate value as described in the doc for the CancelEventArgs Class seems
to obviate the problem. I don't completely understand how this works (e.g. it
does not seem to return control to the user the way I might expect), but it
solves the problem.
pbromberg@gmail.com - 23 Dec 2005 15:27 GMT
Take a look at the Form class's events. "Closing" is probably what you
want to use.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemwindowsformsformclasstopic.asp
Peter