473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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_clicked ??

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 2005
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_clicked ??
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.show' 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_clicked ??
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
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...
2
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...
2
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...
2
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...
10
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...
2
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...
2
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...
4
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...
5
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)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.