.NET

Reply
Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 11 of 17 (271 Views)

Re: Create DBTEXT element in BackgroundWorker vb .net?

06-08-2012 01:11 PM in reply to: prmgame

Exactly. When your worker finishes you could return a collection of ObjectIds to the main thread. Then you wouldn't have to search for them, nor would you be unnecessarily opening and applying the DBText.AdjustAlignment() method to text entities that existed in the database before you ran the worker.

I'm not sure how much difference this will make. I'm thinking it would depend upon on how many other entities (particularly text entities) you have in your drawings. But this is what I would do.

For an example of how to return data from a background worker you can refer to the "Return a value from the background operation" at the bottom of this post :
http://www.c-sharpcorner.com/uploadfile/Ashush/using-the-backgroundworker-component/

Art

Contributor
prmgame
Posts: 12
Registered: ‎08-31-2011
Message 12 of 17 (253 Views)

Re: Create DBTEXT element in BackgroundWorker vb .net?

06-10-2012 06:31 AM in reply to: Artvegas

I understand I did what you recommended and it worked perfectly, had a gain in performance and I am pleased with the results, and again thank Artvegas!

Employee
artc2
Posts: 209
Registered: ‎06-08-2010
Message 13 of 17 (249 Views)

Re: Create DBTEXT element in BackgroundWorker vb .net?

06-10-2012 09:01 AM in reply to: prmgame

I just wanted to re-iterate the warning that someone else already made that AcDb (the entity code) is absolutely not multi-thread safe.  So, while your background thread is running, if the Acad main thread does anything that uses any of the AcDb code that text is using, you are very likely to have problems.

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 14 of 17 (243 Views)

Re: Create DBTEXT element in BackgroundWorker vb .net?

06-10-2012 01:17 PM in reply to: artc2
What artc2 wrote couldn't be any clearer. I would try something like this: http://drive-cad-with-code.blogspot.com.au/2010/12/showing-progress-window-when-running.html
Contributor
prmgame
Posts: 12
Registered: ‎08-31-2011
Message 15 of 17 (235 Views)

Re: Create DBTEXT element in BackgroundWorker vb .net?

06-10-2012 05:42 PM in reply to: artc2

I understand that the risk of performing transactions outside the main thread can cause problems, but I've imported some 368,000 objects between (Polylines, Text, Blocks etc. ..), and so far had no problems, saved the file its countless times and performed tests and everything is correct.  Yet another study it more secure way to do the job, and I am studying the proposal made in a video (taget Gopinath, member of the Autodesk Developer), which teaches how to work with multi-thread smoothly.

 

Parallel Programming in an AutoCAD® Application

http://au.autodesk.com/?nd=class&session_id=8975

 

Thank Staff.

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 16 of 17 (211 Views)

Re: Create DBTEXT element in BackgroundWorker vb .net?

06-11-2012 11:34 AM in reply to: prmgame

Hi prmgame,

 

I just came across a link for another class at Autodesk University...

 

Multithreading and Message Handling in Windows® Presentation Foundation (WPF) Applications:
http://au.autodesk.com/?nd=class&session_id=8964

 

And the class description...

"If your AutoCAD® plug-in spends a long time processing data, you know how frustrated your users can get when their user interface freezes or Windows shows that all too familiar "Program Not Responding" message. How do you prevent that? Depending on what you are doing, you have a choice between message handling and multithreading. This class will show you when to use each technique and how to handle them both from within your WPF user interface."

 

I haven't watched it yet but it seems that this discusses the exact issue you are trying to address - so hopefully will be most useful to you.

Contributor
prmgame
Posts: 12
Registered: ‎08-31-2011
Message 17 of 17 (205 Views)

Re: Create DBTEXT element in BackgroundWorker vb .net?

06-11-2012 01:08 PM in reply to: Artvegas

Hello Artvegas, 

 Yes, I'm watching the videos Autodesk AU, no doubt I'll be doing tests with the examples shown.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.