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 827883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:38:31+00:00 2026-05-15T03:38:31+00:00

I need to create a C++/CLI mixed assembly that can schedule future calls into

  • 0

I need to create a C++/CLI mixed assembly that can schedule future calls into a native DLL with millisecond accuracy.

This will, of course, mean setting a timer (what kind?) for a millisecond or three beforehand, then spinning until the moment and calling the native DLL function.

Based on what I’ve read, I would guess that the callback that the timer calls will need to be native to make sure there are no thunks or GC to delay handling the timer callback.

Will the entire thread or process need to be native and CLR-free, though, or can this be done just as accurately with #pragma unmanaged or setting one file of the assembly to compile as native?

If so, how?

If there is indeed no way to do this in mixed-mode C++/CLI, what would be the easiest way to set up an app/thread (ie, DLL or exe?) to handle it and to get the data back and forth between the native and managed threads/apps?

  • 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-05-15T03:38:32+00:00Added an answer on May 15, 2026 at 3:38 am

    You do need the entire thread to be CLR-free. As soon as any managed code runs on the thread, it will get added to the CLR’s list of threads to suspend during collection.

    Your last question, though, suggests that you have no clue about multithreading. There is no correspondence between threads and DLLs. A DLL can have many threads, and each thread can run code from many DLLs (in fact, always does, if you count Windows DLLs). You’re also not using the phrase “critical section” in the usual way.

    A mixed-mode C++/CLI assembly can contain a native-only thread (start it using the native CreateThread call, passing a native thread procedure, and don’t call any managed code directly or indirectly from that thread). Your life will be a little easier if you write the code for the native thread in one or more files set to compile without /clr, not having managed code visible makes it easier to avoid calling it, although beware of function pointers which might be wrapping managed delegates.

    Beyond that, use lock-free synchronization, e.g. SList, or your native thread could end up waiting for a lock held on a mixed-mode thread which has been suspended for garbage collection. Among other things this means not using any of the standard shared allocators, because they use locking internally. Some lock-free allocators do exist though.

    EDIT: Function pointers which wrap managed delegates are created by calling Marshal::GetDelegateForFunctionPointer. After that, they act just like pointers to native functions (it is possible to tell them apart) and using the function call operator on such a pointer will cause managed code to run on the sensitive thread. In most cases this won’t be a problem, just make sure if you are using delegates as a shortcut to produce callbacks to managed code, that you do so from the mixed thread and not the one you intend to be native-only.

    In general, you’ll probably want some sort of purely native message passing scheme to exchange data. The mixed thread can make whatever native calls are necessary, you can mix native and managed code on all your other threads, just keep the time-sensitive one native-only.

    All thunking should occur on the mixed thread, and it won’t delay the time-sensitive native thread unless the mixed thread is holding a lock that the native thread needs. Hence my suggestion to use non-locking data exchange.

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

Sidebar

Related Questions

I need create custom dialog and put JPanel into it. Is it possible?
I need create clone repository. but I do not know where can I get
I need create a document word with Java. And I ask, how can I
I have a native C++ DLL that uses COM ADO Recordsets and am in
I've created a mixed DLL (C++/CLI) and after successfully calling it from a plain
I have a C++ class that I need to create several instances of in
I have a C++/CLI project that uses CWinFormsControl and CWinFormsView to create .NET controls
I have a method in my native dll, that I want to use. The
I need create a SQL Server stored procedure that does the following: Take an
I need to create a server-side app that saving information to a mongoDB ,

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.