Hi again,
If I was to get the AutoCAD 2006 upgrade and react to the
EnteringQuiescentState event as you suggested, do you think I'd be able to
accomplish my goal?
Maybe the method could go something like this:
-React to EnteringQuiescentState event
-while (true)
{
-Check my database for alerts
-If there's an alert, make a change in AutoCAD
-Check to see if we are not in a quiescent state any more
-If we are not, break out of while loop
}
The main thing is that the code should continue checking for alerts again
and again. If the user wants to do something, it could stop and give
control back to the user.
It's not enough to just check the database once each time the quiescent
state is entered. In case the user sits around and leaves AutoCAD running
for a long time without doing anything, I want them to be notified of an
alert as soon as possible.
Do you think this would work in AutoCAD 2006?
Thanks.
-Carlos
"Tony Tanzillo" wrote in message
news:4925561@discussion.autodesk.com...
The event I mentioned is only available in 2006
(and later, assuming they don't change things
again). My advice to anyone regarding .NET in
2005, is to not invest any major effort in that
release of the API.
Regardless of that, I am not sure I understand
what the intent of your code is. It makes no sense
to start a thread; then abort it; then enter a loop
that executes infinitely and does nothing but calls
Sleep(). Sleep() will cause the calling thread to
block for the specified time. Since the thread you
aborted is not running when you get to the while()
loop, IsAlive will always return false and the loop
will execute infinitely.
I don't think I understand what the intent is there.
Lastly, you call Join() on a thread that is not
running to begin with (because you aborted it
with the call to Abort()).
Does the CommandMethod you show actually
return control to the Command: line when you
execute it? From the looks of the code, that is
not going to happen, and all that command is
going to do is block the document's thread,
causing AutoCAD to not respond to mouse or
keyboard input.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
"Carlos" wrote in message
news:4925444@discussion.autodesk.com...
Hi,
I'm using AutoCAD 2005 and VS 2003, and I can't find anything about the
EnteringQuiescentState event. Is that only in 2006?
The database (not the AutoCAD database, but a different one external to
AutoCAD, accessed by my DLL via C# web services) that I mentioned stores
important alerts. Somehow, I need to check this database (about once per
second) and send the user a message in AutoCAD if there are any new alerts.
Ideally, this would occur even if the user was busy working on something
else in the drawing (so it's busy running one function again and again to
check for alerts while the user is doing other stuff and calling other
functions).
It would be alright with me if the alerts database was queried only when the
user wasn't doing anything, but it would still have to occur frequently
while the user idles. These queries would then have to be interrupted if
the user started doing something.
Is this sort of thing possible?
Thank you very much for your help. I really appreciate it.
-Carlos
"Tony Tanzillo" wrote in message
news:4925222@discussion.autodesk.com...
Why not ditch the thread, and query the database
for changes from the EnteringQuiescentState event
of the Editor? That's the only time that it would be
appropriate to take control of the editor away from
the user anyway.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
"Carlos" wrote in message
news:4924984@discussion.autodesk.com...
Hi,
I've got a database that I access through C# web services. I need to update
an AutoCAD drawing if anything in that database changes. I've created a
thread that regularly asks the database if there is anything new. If there
is, I'd like to somehow make some changes in AutoCAD. Is this possible?
Can I trigger an event in AutoCAD from a seperate thread?
Here's how I make the thread:
[CommandMethod("StartPollingForEvents")]
public static void StartPollingForEvents()
{
// Define the thread's target method
PollingManager pollingManager = new PollingManager();
Thread t = new Thread(new ThreadStart
(pollingManager.ExecuteThread));
// Start the thread
t.Start();
t.Abort();
while (!t.IsAlive);
Thread.Sleep(100);
t.Join();
}
Here's the thread's target method:
public void ExecuteThread()
{
CommandLinePrompts.Message("\n ExecuteThread method entered.");
while(true)
{
CommandLinePrompts.Message("\n Output from thread...");
}
}
I get no output to the command line when I run this code.
Thanks very much for any help or ideas.
-Carlos