473,761 Members | 10,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pinvoke causes loss of modal dialog modality?

have a 3rd party .Net dll that wraps a set of further unmanaged dll's. The
..Net DLL basically uses pinvoke to wrap the calls. The low level dlls
provide an API to talk to a complex device which appears as a USB hub (with a
scanner, flash drive and some other bits and pieces).

Using a VB.Net windows app, we call the main unmanaged API function (lets
call it doStuff() ) and then call messagebox.show to pop up a modal results
dialog. This works OK UNLESS the client app loses while dostuff() is runnning
(takes about 5 - 10 seconds)

If this happens the modal dialog pops up but isn't modal! You can then click
the 'Dostuff' button on the app and call doStuff() again. It's either
resulting in multiple threads of execution or recursive calls to
on_dostuff_clic ked ??

This only appears to happen when the client app loses focus while execution
is in the unmanaged code. If it doesn't then the modal is modal.

Anyone come across anything like this before ? Is there any way of
isolating the call to the 3rd party API so it doesn't mess up the calling app?

Cheers,

Rob J
Nov 22 '05 #1
2 2028
On Wed, 13 Jul 2005 03:00:02 -0700, RobJUK66 wrote:
Using a VB.Net windows app, we call the main unmanaged API function (lets
call it doStuff() ) and then call messagebox.show to pop up a modal results
dialog. This works OK UNLESS the client app loses while dostuff() is runnning
(takes about 5 - 10 seconds)

If this happens the modal dialog pops up but isn't modal! You can then click
the 'Dostuff' button on the app and call doStuff() again. It's either
resulting in multiple threads of execution or recursive calls to
on_dostuff_clic ked ??
Anyone come across anything like this before ? Is there any way of
isolating the call to the 3rd party API so it doesn't mess up the calling app?


I do not think that your pinvoke calls have anything to do with the modal
messagebox being not modal anymore. From what you are saying, you have a
form with a Dostuff button on it. When the user clicks this button, your
are calling the doStuff() wrapper method and then MessageBox.Show (), is
that right? It seems a bit strange to me since you are saying that
doStuff() takes 5-10 seconds to execute which means that your app is frozen
during 5-10 seconds whenever the user clicks on the Dostuff button, not
something the users usually appreciate. Are you sure that you are not
starting a thread to do the processing and calling the MessageBox.Show from
this other thread? Also, are you passing a reference to your main form
('Me') as the owner parameter when you are calling MessageBox.Show ?
Nov 22 '05 #2

I don't want the user to be able to do anything while this eternal API
executes.
I make the call via the supplied .Net API (which in turn pInvokes).
messagebox.show is called immediatly afterwards.

Now for something REALLY odd...

If I run 'Process Explorer' (an exclellent, free sysinternals utility) I can
see the .Net thread count (Under .Net CLR Locks&Threads). If I comment out
the 'messagebox.sho w' then the thread count is correct and unchanging. IF I
call messagebox.show after the 3rd Party API call the thread count increases
by one each time!!

Now, why on earth would adding a message box call after a (abtracted)
pinvoke cause an extra thread to be created ??
"Mehdi" wrote:
On Wed, 13 Jul 2005 03:00:02 -0700, RobJUK66 wrote:
Using a VB.Net windows app, we call the main unmanaged API function (lets
call it doStuff() ) and then call messagebox.show to pop up a modal results
dialog. This works OK UNLESS the client app loses while dostuff() is runnning
(takes about 5 - 10 seconds)

If this happens the modal dialog pops up but isn't modal! You can then click
the 'Dostuff' button on the app and call doStuff() again. It's either
resulting in multiple threads of execution or recursive calls to
on_dostuff_clic ked ??
Anyone come across anything like this before ? Is there any way of
isolating the call to the 3rd party API so it doesn't mess up the calling app?


I do not think that your pinvoke calls have anything to do with the modal
messagebox being not modal anymore. From what you are saying, you have a
form with a Dostuff button on it. When the user clicks this button, your
are calling the doStuff() wrapper method and then MessageBox.Show (), is
that right? It seems a bit strange to me since you are saying that
doStuff() takes 5-10 seconds to execute which means that your app is frozen
during 5-10 seconds whenever the user clicks on the Dostuff button, not
something the users usually appreciate. Are you sure that you are not
starting a thread to do the processing and calling the MessageBox.Show from
this other thread? Also, are you passing a reference to your main form
('Me') as the owner parameter when you are calling MessageBox.Show ?

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6733
by: Gilles T. | last post by:
Hi, How I can refresh a modal dialog in asp.net? I open a modal dialog in first with a dropdownlist. To add a element in my dropdownlist (table), I open a second modal dialog to ask element and save. When I return in my first modal dialog, dropdownlist is not refreshed. I don't know how to refresh my first modal dialog to view my new element in the dropdownlist. Thanks to help me with this problem!
2
445
by: RobJUK66 | last post by:
have a 3rd party .Net dll that wraps a set of further unmanaged dll's. The ..Net DLL basically uses pinvoke to wrap the calls. The low level dlls provide an API to talk to a complex device which appears as a USB hub (with a scanner, flash drive and some other bits and pieces). Using a VB.Net windows app, we call the main unmanaged API function (lets call it doStuff() ) and then call messagebox.show to pop up a modal results dialog. This...
2
2559
by: cassidyc | last post by:
Hi, I was wondering if anyone has come accross this issue? And if they have any solutions I have that can create new copies of itself Form1 as = new form1(); af.show(); This form can also bring up a modal dialog (MessageBox)
2
4938
by: Ricky K. Rasmussen | last post by:
Hi NG, We have a rather large ASP.NET application that uses popups to display various dialogs to the user. In our work we've come over a rather annoying "bug": If we open a modal dialog using the javascript command window.showModalDialog() we loose the current Session if a new window is opend from within the modal one (using the window.open() method). The "funny" thing is that this only occurs if another instance of IE has been
10
2755
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a preview DIV) 2. when users close the dialog, the application receives the URL to the selected graphic. 3. the modal dialog lets the users upload a new graphic if the dialog does not present them with one they are already happy with. 4. upon uploading...
2
3686
by: sthrudel | last post by:
Hi! I'm working on a web application in Asp.net and what I would like to have is a cross borwser modal dialog which accepts user's input. I would like to catch what the user clicked on the dialog. To be more specific I want to have a confirmation dialog that is shown when a user clicks on a Delete button (which deletes some values from database). If Yes is pressed the delete action is processed otherwise modal dialog is closed.
2
2127
by: NickP | last post by:
Hi there, I was wondering if there was any way to stop the hiding of a dialog from returning from the ShowDialog function? i.e. If you create your own dialog and put some code in that hides it temporarily during it's use, the ShowDialog function will return the second it is hidden, this is the same for ".Hide()" as well as sending ShowWindow(...SW_HIDE).
4
10636
by: John Kotuby | last post by:
Hi all... I am bulding an application and wish to use custom Modal dialog windows. According to a couple of recent articles I have seen, the newer Mozilla browsers (actually I think they said Netscape) supported syntax like : window.open(URL ,"diagwin","modal=1, width=30"); For IE I use : window.showModalDialog
5
2944
by: GraffixNYC | last post by:
We have a model dialog box(well a bunch of them) and it seems that when you cancel one of the in our application it will activate and bring the focus to another open window (not in our application) anyone know why this is and how to correct it? it should set the focus to our application and not "activate" another window and make that window have the focus
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.