OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: jmaeding on November 03, 2011, 03:01:30 PM

Title: Getting wait cursor after a few seconds, then progress bar not updating
Post by: jmaeding on November 03, 2011, 03:01:30 PM
I am on Civil 3D2009 (runs as 32 bit prog) in windows 7
64bit. I have a modal form that counts app ids in files in a loop.
It has a progress bar that tracks the progress.
If the operation takes more than a few seconds, I get the little circle that spins, and acad essentially freezes until the looping is done.
Is there a way to get the form to refresh once per loop?  I tried several things as the first statement inside my loop.
set focus, redraw, and anything that made sense in the object broswer.
Is this something everyone sees, or just my 2009/win 7 64 combination.
Any suggestions?
thx
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: Fred Tomke on November 03, 2011, 10:05:34 PM
Hi, yes I do know this. If you have luck, then dcl_Control_Redraw causes repainting the control, but there's no guarantee.
In the end you won't have any chance to solve this because your loop and your form seem to run in the same thread (Owen may correct me). And since Lisp does not allow multithreading you can't avoid this.

You can try the following:
Build a modeless form. Create a progress bar and a button on it. Let the button call the event asynchronously (by setting EventInvoke to AllowCommand) and excecute your counting from this event. I just want to know if there's a difference, because a running modal form "stops" AutoCAD for the time (dcl_form_show ...) is running.

And another thing: if you have 100.000 loops then you shouldn't call (dcl_control_setvalue oProgress (setq intCnt (1+ intCnt))) each time because it takes a recognizable amount of time.

Regards, Fred
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: marcoheuer on November 03, 2011, 11:58:56 PM
hello,
the fundamental problem i'm just trying to solve here http://www.theswamp.org/index.php?topic=39931.0 (http://www.theswamp.org/index.php?topic=39931.0) and here http://ww3.cad.de/foren/ubb/Forum145/HTML/003518.shtml (http://ww3.cad.de/foren/ubb/Forum145/HTML/003518.shtml).
i use among other things modeless dialogs with progressbar (EventInvoke: AllowCommand). that also occurs the problem. it does not seem to lie at opendcl.

the problem seems to be, that is until autocad no feedback to the system as long as the lisp routine runs. when I break the program in the debugger and let continue to run it behaves autocad for some time normal (also progressbars).

best regards
marco

(sorry for my english)
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: Fred Tomke on November 04, 2011, 12:46:54 AM
Hi, Marco, thanks for sharing your experiences. I can reproduce this behavior in my C# projects outside AutoCAD when I'm too lazy to create another thread for the time-expensive methods. So at least we have to live with it.

Regards, Fred
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: marcoheuer on November 04, 2011, 01:53:11 AM
but this is not like the customer  :(
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: jmaeding on November 04, 2011, 09:28:41 AM
ah, so the only answer is to sub out the task to a .net command.
That actually fits fine with me, as I am just finishing my set of functions in lisp and .net that serialize and deserialize a list/arraylist so I can pass strings back and forth in the resultbuffer.
Turns out 2009, at least, handles certain things in funcky ways, such as a list of three numbers.
I posted in the adesk groups on this and they confirmed it, so I have to resort to passing strings which are not "reinterpreted" by the .net list to resultbuffer translation the lispfunction mechanism performs.

Maybe I just expose my loop task function from my vlx so .net can start the loop, and call the lisp function, then do the progress report.  I am starting to mix lisp and .net a lot now, its awesome as you can take advantage of both sets of tools.
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: marcoheuer on November 05, 2011, 02:59:28 AM
hello,
is there possibility to call from c# a lisp function?
in the way:
- start function in c# with parameters lispfunctionname
- in this function start the lispfunction

and would this solve the problem?

best regards
marco
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: Kerry on November 05, 2011, 03:14:39 AM

Marco,
I've answered your post at theSwamp

Although I enjoy .NET you don't need it in this case ... depending on your actual problem :)
Title: Re: Getting wait cursor after a few seconds, then progress bar not updating
Post by: Fred Tomke on November 06, 2011, 01:50:39 AM
Hello,

interacting AutoLISP and C# works fine as long you don't send many data between C# and Lisp. In my experiences it takes a recognizable time for AutoCAD to send a large ResultBuffer (for instance of a list with dotted pairs) from .NET to Lisp.

Regards, Fred