Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8421485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:09:53+00:00 2026-06-10T03:09:53+00:00

The API doesn’t officially support threading (see below) or a way to close an

  • 0

The API doesn’t officially support threading (see below) or a way to close an active document. That said, a work around to closing an active document is to call…

SendKeys.SendWait("^{F4}");

…from a separate thread. That works fine, except I need to loop through opening and closing several documents. If I put any code at all after thread, it will run it before closing the previous document. I have tried a number of standard threading callback methods including…

Task.Factory.StartNew(() =>

ThreadPool.QueueUserWorkItem(new WaitCallback

AutoResetEvent.WaitOne()

with no luck. And Thread.Sleep() just stalls the error/crash. Does anyone have any ideas.

“Revit’s internals make use of multiprocessing in only a few select isolated locations. None of these locations currently encompass the code in the Revit API, or any part of it. Thus Autodesk does not recommend making any calls to the Revit API from within simultaneously executing parallel threads. It may be that some part of the Revit API is isolated enough to be able to execute successfully from within such threading code in a test environment; this should not be taken to be a guarantee that the same source code will function for any model or situation, or that a future change in Revit will not cause this code to cease to function.”

    public void OpenFile()
    {
        for (int i = 0; i < 3; i++)
        {
            uiApp.OpenAndActivateDocument(TargetPath(i));

            ThreadPool.QueueUserWorkItem(CloseDocProc);

            //any code here at all opens the next doc without closing the last
        }            
    }

    public void CloseDocProc(object stateInfo)
    {
        SendKeys.SendWait("^{F4}");

        //can run code here
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:09:55+00:00Added an answer on June 10, 2026 at 3:09 am

    The problem was the threading, just like they said. Using any of the callback methods it would freeze right at that point. And you can only do a limited number of things in the thread, it would not let me open a document, no matter what!

    The answer was to use a single-threaded timer.

    System.Windows.Forms.Timer;
    

    calling my Open() method every 10 seconds or so and stopping the timer and running the last bit of code when a counter reached a certain point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Starting from this official statement that all xyAndroid versions previous API 11 doesn't support
This is not close to real situation, but it shows that Expressions API doesn't
Google Maps API V3 doesn't support the V2 GOverviewMapControl option, yet. I've come across
It seems Zend Gdata doesn't provide a way to interface with the PUT API
I'm using Google API 8 (Android 2.2) with support package v4. It doesn't give
Looking through the documentation , it seems that the new advanced gestures API doesn't
The Facebook API doesn't work in Opera: FB.Canvas.setSize - not change a canvas size.
It's well-known on Android discussion forums and SO that Android's API doesn't have a
The Office 2007 interop API doesn't provide any event on document changes. How can
Microsoft's own PHP example for new Bing API doesn't work. I tried in many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.