CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 01-13-2013, 12:58 AM   #1
MikieK
PRO
portfolio
Mike Kovacic
Melbourne, Australia
 
Join Date: Aug 2009
Posts: 196
prevent hang in intensive c# calcs

Greetings

Is there an equivalent to
windows.processPostedMessages()
in c#?

I'm getting a windows 7 white screen hang, with AppHangB1 as the listed problem when running a long calculation from a c# Method.

The best I can figure is the method is taking longer than 3ds Max UI thread (or windows?) is willing to allow. In Maxscript I would have just processed the messages every once in a while to keep that from happening.

In Visual studio, if I attach to 3ds max process, and iterate through the loops, I get about a dozen loops in before it hangs. There is no exception, thrown. (as it's the attached process that hangs, not my c# code)

Any advice?


Cheers

Mikie
 
Old 01-13-2013, 01:38 AM   #2
Gravey
3D Dude
Joel Hewitt
Sydney, Australia
 
Join Date: Dec 2005
Posts: 880
three things:

1) i believe processPostedMessages is the same as or similar to Application.DoEvents() in C# BUT i also believe it is EVIL and should never be called! For example, create a rollout with a button that starts some long process and press it to begin. you accidently click the button again while processing. no big deal, nothing happened. Somewhere during your long process code you call Application.DoEvents() causing that button click to be processed and basically everything just explodes.

2) to stop the windows ghosting problem, which may be all you need, someone provided some code to disable it for max which can be run on startup. search windows ghosting on this forum.

3) without knowing anything about your code, maybe try the backgroundworker for the C# parts if they can be processed out of order?
 
Old 01-13-2013, 02:22 AM   #3
MikieK
PRO
portfolio
Mike Kovacic
Melbourne, Australia
 
Join Date: Aug 2009
Posts: 196
Quote:
Originally Posted by Gravey
three things:

1) i believe processPostedMessages is the same as or similar to Application.DoEvents() in C# BUT i also believe it is EVIL and should never be called! For example, create a rollout with a button that starts some long process and press it to begin. you accidently click the button again while processing. no big deal, nothing happened. Somewhere during your long process code you call Application.DoEvents() causing that button click to be processed and basically everything just explodes.

2) to stop the windows ghosting problem, which may be all you need, someone provided some code to disable it for max which can be run on startup. search windows ghosting on this forum.

3) without knowing anything about your code, maybe try the backgroundworker for the C# parts if they can be processed out of order?


I think I need to invoke and thread it properly. As I compile to a library .dll I don't think I can reference Application (afaik).

The only difference when Enabling windows ghosting is that I need to ctrl-alt-del to end process.

They can't be processed out of order unfortunately. Worst case I can run the loop in maxscript... but it's sloooow
 
Old 01-13-2013, 02:51 AM   #4
MikieK
PRO
portfolio
Mike Kovacic
Melbourne, Australia
 
Join Date: Aug 2009
Posts: 196
how odd. it still hangs when I run the loop in maxscript, at exactly the same point in the loop (the 13th iteration), even when I run windows.processPostedMessages() every loop.

Wish I got a bloody exception error. This is really annoying.
 
Old 01-13-2013, 04:27 AM   #5
Gravey
3D Dude
Joel Hewitt
Sydney, Australia
 
Join Date: Dec 2005
Posts: 880
Quote:
Originally Posted by MikieK
how odd. it still hangs when I run the loop in maxscript, at exactly the same point in the loop (the 13th iteration), even when I run windows.processPostedMessages() every loop.

Wish I got a bloody exception error. This is really annoying.
so max isn't just hanging until the end of the calc? it's locking up until you close it right?
 
Old 01-13-2013, 05:02 AM   #6
MikieK
PRO
portfolio
Mike Kovacic
Melbourne, Australia
 
Join Date: Aug 2009
Posts: 196
what a slog.

after much error trapping, I found a while loop in some code I did not write which was not exiting in certain situations. It was about 2 classes, and 4 methods removed from where I was looking. The only way I found it was to keep putting breakpoints farther and farther in, till I found it.

Is there any way in visual studio, when attached to a process, to see where the code is currently executing/running?

So in the end, this stuff does take 30 seconds to a minute to run, and the hanging, was in actual fact, hanging.
 
Old 01-13-2013, 05:04 AM   #7
Gravey
3D Dude
Joel Hewitt
Sydney, Australia
 
Join Date: Dec 2005
Posts: 880
debug menu - break all ???
 
Old 01-13-2013, 05:07 AM   #8
MikieK
PRO
portfolio
Mike Kovacic
Melbourne, Australia
 
Join Date: Aug 2009
Posts: 196
*googles "break all" *
*slaps forehead*

So that's what that little pause button is for...

thanks!!!
 
Old 01-13-2013, 08:14 AM   #9
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,839
Quote:
Originally Posted by MikieK
As I compile to a library .dll I don't think I can reference Application (afaik)


Not true. Application is static, and is in the same AppDomain as anything else run in the 3dsmax process.
 
Old 01-13-2013, 08:14 AM   #10
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:38 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.