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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:06:57+00:00 2026-05-30T08:06:57+00:00

I am working on a C# application and facing a strange issue here. I

  • 0

I am working on a C# application and facing a strange issue here. I have a .dll which has been built in C++, and I have to call some functions from this .dll from C# app.

Consider this sample code:

public partial class MainWindows: Window
{
public MainWindow()
{
InitializeComponent();
ConfigurationFunctions.StartMain(); //Start main is the DLL function in C++ 

int x = ConfigurationFunctions.ReturnIntExp();
StringBuilder sb = ConfigurationOptions.ReturnSomethingExp();
}
}

C++ .cpp file

EXPORT_API int xExp;
EXPORT_API char cExp; 
EXPORT_API StartMain()
{
//Calculate `x` and `y` in this program values here and allocate to variables to be returned from function
xExp = x;
cExp = c;
}
EXPORT_API int ReturnIntExp()
{
return xExp;
}
EXPORT_API char ReturnSomethingExp()
{
return cExp;
}

The problem is when I run the StartMain() function from the .dll, it calculate some values for for int and char which have to be allocated to variables (that are actually returned to C# application)

But, after StartMain() the C# application should wait till the StartMain() function is complete (which in this case takes approx. 3-4 secs and the dll itself fires two/three other processes) and only then proceed further or else, the variables x and sb in C# application will have empty/meaningless values.

How can I achieve the same in this case?

  • 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-30T08:06:58+00:00Added an answer on May 30, 2026 at 8:06 am

    Add a third exported variable ReturnIsReady() that returns true if the other two methods have meaningful data, and false otherwise. Then simply have a loop with a sleep to check that value until it changes.

    A better option would be to implement a mutex or similar structure, but spin waiting should be sufficient for a single wait of that length at start up.

    Alternatively, why is StartMain() returning before filling in the values?

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

Sidebar

Related Questions

I am working on a Google App Engine application, and have been facing some
I have a strange issue in my GWT app. My application is working fine
here's another strange behaviour I'm currently facing. I have an application deployed on a
I'm working on an application where users have to make a call and type
I am facing a strange issue of different behavior of a same web application
I have been facing a strange problem while returning dataset through WCF service (WSHttpBinding).
I am facing a strange issue in my Zend Application: My model is like
I am facing a strange problem while running my application. I have a class
I am facing a problem in my application. I have some section in application
I am facing a strange problem here. I have two projects, each of them

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.