Notifications
Clear all

[Closed] 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

8 Replies

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?

1 Reply
(@mikiek)
Joined: 11 months ago

Posts: 0

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

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.

1 Reply
(@gravey)
Joined: 11 months ago

Posts: 0

so max isn’t just hanging until the end of the calc? it’s locking up until you close it right?

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.

debug menu – break all ???

*googles “break all” *
slaps forehead

So that’s what that little pause button is for…

thanks!!!

 lo1

Not true. Application is static, and is in the same AppDomain as anything else run in the 3dsmax process.