473,799 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Process won't die when form is closed.

I have a form which displays a DataGridView table generated with the VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to close
the form the .exe refuses to die and has to be killed in Task manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button onto
the form and put "this.Close ();" in for it's event but I get the same
result.

Using trial/error troubleshooting seems to point to some of the generated
code behind the TableAdapter. If I comment it out the form closes properly
but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may or may
not be related.

My next step is to start over from scratch since it's fairly easy to rebuild
once I have screenshots of my queries etc...

Edwin
Feb 26 '07 #1
13 7358
Try call Application.Exi t() instead.

If it works, check the line Application.Run () whether it is the form your
DataGridView is running on.

If not, run it in Debug mode. Try closing the application and click Pause
after the screen goes off to see where your code stuck at.

"Edwin Smith" <sm**********@a ol.com¼¶¼g©ó¶l¥ ó·s»D:uG******* *******@TK2MSFT NGP05.phx.gbl.. .
>I have a form which displays a DataGridView table generated with the VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to
close the form the .exe refuses to die and has to be killed in Task
manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button
onto the form and put "this.Close ();" in for it's event but I get the same
result.

Using trial/error troubleshooting seems to point to some of the generated
code behind the TableAdapter. If I comment it out the form closes properly
but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may or
may not be related.

My next step is to start over from scratch since it's fairly easy to
rebuild once I have screenshots of my queries etc...

Edwin


Feb 26 '07 #2
On Feb 25, 9:15 pm, "Edwin Smith" <smithgold...@a ol.comwrote:
I have a form which displays a DataGridView table generated with the VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to close
the form the .exe refuses to die and has to be killed in Task manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button onto
the form and put "this.Close ();" in for it's event but I get the same
result.

Using trial/error troubleshooting seems to point to some of the generated
code behind the TableAdapter. If I comment it out the form closes properly
but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may or may
not be related.

My next step is to start over from scratch since it's fairly easy to rebuild
once I have screenshots of my queries etc...
This sounds like a background thread that isn't marked "background ".
The application shuts down only when all foreground threads have
stopped executing. If your code starts a background thread to do some
long-running task (like fetching data from a database) and doesn't
mark the thread "IsBackgrou nd", then the thread will keep your
application alive.

You'll have to find the code that starts the background thread and
ensure that the thread's IsBackground property is set to true.

Feb 26 '07 #3
When I run it in debug mode it works fine and exits properly. Of course the
app doesn't run in it's own executable then, it's running in the debugger so
the debugger doesn't tell me anything.

If I run it in it's own executable then when I click the X on the form or
click the close button I added, the form closes but the app is still running
in memory and is "orpahned".

I'll look for the "background thread" problem suggested in the other reply
to my post.

Thanks

Edwin

"Lau Lei Cheong" <le****@yehoo.c om.hkwrote in message
news:OP******** ******@TK2MSFTN GP04.phx.gbl...
Try call Application.Exi t() instead.

If it works, check the line Application.Run () whether it is the form your
DataGridView is running on.

If not, run it in Debug mode. Try closing the application and click Pause
after the screen goes off to see where your code stuck at.

"Edwin Smith" <sm**********@a ol.com>
¼¶¼g©ó¶l¥ó·s»D: uG************* *@TK2MSFTNGP05. phx.gbl...
>>I have a form which displays a DataGridView table generated with the
VS2005 tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to
close the form the .exe refuses to die and has to be killed in Task
manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button
onto the form and put "this.Close ();" in for it's event but I get the
same result.

Using trial/error troubleshooting seems to point to some of the generated
code behind the TableAdapter. If I comment it out the form closes
properly but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may or
may not be related.

My next step is to start over from scratch since it's fairly easy to
rebuild once I have screenshots of my queries etc...

Edwin



Feb 26 '07 #4

"Bruce Wood" <br*******@cana da.comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
On Feb 25, 9:15 pm, "Edwin Smith" <smithgold...@a ol.comwrote:
>I have a form which displays a DataGridView table generated with the
VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to
close
the form the .exe refuses to die and has to be killed in Task manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button
onto
the form and put "this.Close ();" in for it's event but I get the same
result.

Using trial/error troubleshooting seems to point to some of the generated
code behind the TableAdapter. If I comment it out the form closes
properly
but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may or
may
not be related.

My next step is to start over from scratch since it's fairly easy to
rebuild
once I have screenshots of my queries etc...

This sounds like a background thread that isn't marked "background ".
The application shuts down only when all foreground threads have
stopped executing. If your code starts a background thread to do some
long-running task (like fetching data from a database) and doesn't
mark the thread "IsBackgrou nd", then the thread will keep your
application alive.

You'll have to find the code that starts the background thread and
ensure that the thread's IsBackground property is set to true.
I never know whether it's proper to reply before or after the quoted text.

The database code is generated by VS2005 code behind the TableAdapter. I can
trace through it with the debugger so I'll see if there's any IsBackground
properties. Or do you mean there is an IsBackground property that can be set
in the visual designer? I'll check those.

Thanks

Edwin
Feb 26 '07 #5

"Bruce Wood" <br*******@cana da.comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
On Feb 25, 9:15 pm, "Edwin Smith" <smithgold...@a ol.comwrote:
>I have a form which displays a DataGridView table generated with the
VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to
close
the form the .exe refuses to die and has to be killed in Task manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button
onto
the form and put "this.Close ();" in for it's event but I get the same
result.

Using trial/error troubleshooting seems to point to some of the generated
code behind the TableAdapter. If I comment it out the form closes
properly
but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may or
may
not be related.

My next step is to start over from scratch since it's fairly easy to
rebuild
once I have screenshots of my queries etc...

This sounds like a background thread that isn't marked "background ".
The application shuts down only when all foreground threads have
stopped executing. If your code starts a background thread to do some
long-running task (like fetching data from a database) and doesn't
mark the thread "IsBackgrou nd", then the thread will keep your
application alive.

You'll have to find the code that starts the background thread and
ensure that the thread's IsBackground property is set to true.
Does the code generator for the TableAdapter.Fi ll generate background
threads for ODBC connections? Since this is filling a DataGridView table it
DOES get the entire table in memory before it displays the form. Then it
disconnects from the database. ( I think)

Or is the background thread just an automagic thing and I have to insert the
IsBackground property somewhere in order for the code to shutdown properly?

I searched the entire project and the text "IsBackgrou nd" does not appear
anywhere.

AFAIK this project runs in a single thread since I have not explicetly set
anything for multithreaded operation. I'm not that sophisticated a
programmer yet so multithreading is way over my head.

Thanks

Edwin
Feb 26 '07 #6
On Feb 26, 12:02 pm, "Edwin Smith" <smithgold...@a ol.comwrote:
AFAIK this project runs in a single thread since I have not explicetly set
anything for multithreaded operation. I'm not that sophisticated a
programmer yet so multithreading is way over my head.
Well, the way to tell is to watch and see whether the user interface
freezes while the application is fetching data from the database. If,
during the data fetch, the application is still responsive, then it's
multi-threading. If it freezes, then the DB fetch is being done on the
UI thread and locking it up.

Try searching your app for "Thread" and see what you find.

Feb 26 '07 #7
"Edwin Smith" <sm**********@a ol.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>
"Bruce Wood" <br*******@cana da.comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
>On Feb 25, 9:15 pm, "Edwin Smith" <smithgold...@a ol.comwrote:
>>I have a form which displays a DataGridView table generated with the VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to close
the form the .exe refuses to die and has to be killed in Task manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button onto
the form and put "this.Close ();" in for it's event but I get the same
result.

Using trial/error troubleshooting seems to point to some of the generated
code behind the TableAdapter. If I comment it out the form closes properly
but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may or may
not be related.

My next step is to start over from scratch since it's fairly easy to rebuild
once I have screenshots of my queries etc...

This sounds like a background thread that isn't marked "background ".
The application shuts down only when all foreground threads have
stopped executing. If your code starts a background thread to do some
long-running task (like fetching data from a database) and doesn't
mark the thread "IsBackgrou nd", then the thread will keep your
application alive.

You'll have to find the code that starts the background thread and
ensure that the thread's IsBackground property is set to true.

Does the code generator for the TableAdapter.Fi ll generate background threads for ODBC
connections? Since this is filling a DataGridView table it DOES get the entire table in
memory before it displays the form. Then it disconnects from the database. ( I think)

Or is the background thread just an automagic thing and I have to insert the IsBackground
property somewhere in order for the code to shutdown properly?

I searched the entire project and the text "IsBackgrou nd" does not appear anywhere.

AFAIK this project runs in a single thread since I have not explicetly set anything for
multithreaded operation. I'm not that sophisticated a programmer yet so multithreading is
way over my head.

Thanks

Edwin

In this case it means that the code is stucked (or deadlocked) in the main thread (are you
sure your Main is marked STAThread ?), probably in the Pervasive ODBC driver.
To be sure you'll have to attach a debugger to the process and check which thread is waiting
and what he is waiting for.
Another option is to get a copy of process explorer (procexp.exe) from www.syinternals.com
(now on msdn) and watch the offending process threads and their stacks.

Willy.

Feb 26 '07 #8

"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:OL******** ******@TK2MSFTN GP05.phx.gbl...
"Edwin Smith" <sm**********@a ol.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>>
"Bruce Wood" <br*******@cana da.comwrote in message
news:11******* *************** @q2g2000cwa.goo glegroups.com.. .
>>On Feb 25, 9:15 pm, "Edwin Smith" <smithgold...@a ol.comwrote:
I have a form which displays a DataGridView table generated with the
VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.

The DataGridView works great except when I'm done and I click the X to
close
the form the .exe refuses to die and has to be killed in Task manager.

I ran a debug trace and it seems to work fine. I dropped a CLOSE button
onto
the form and put "this.Close ();" in for it's event but I get the same
result.

Using trial/error troubleshooting seems to point to some of the
generated
code behind the TableAdapter. If I comment it out the form closes
properly
but then of course my DataGridView doesn't work.

Anyone have a similar problem?

I'm also having a VS2005 lockup problem (on another thread) which may
or may
not be related.

My next step is to start over from scratch since it's fairly easy to
rebuild
once I have screenshots of my queries etc...

This sounds like a background thread that isn't marked "background ".
The application shuts down only when all foreground threads have
stopped executing. If your code starts a background thread to do some
long-running task (like fetching data from a database) and doesn't
mark the thread "IsBackgrou nd", then the thread will keep your
application alive.

You'll have to find the code that starts the background thread and
ensure that the thread's IsBackground property is set to true.

Does the code generator for the TableAdapter.Fi ll generate background
threads for ODBC
connections? Since this is filling a DataGridView table it DOES get the
entire table in
memory before it displays the form. Then it disconnects from the
database. ( I think)

Or is the background thread just an automagic thing and I have to insert
the IsBackground
property somewhere in order for the code to shutdown properly?

I searched the entire project and the text "IsBackgrou nd" does not
appear anywhere.

AFAIK this project runs in a single thread since I have not explicetly
set anything for
multithreade d operation. I'm not that sophisticated a programmer yet so
multithreadi ng is
way over my head.

Thanks

Edwin


In this case it means that the code is stucked (or deadlocked) in the main
thread (are you
sure your Main is marked STAThread ?), probably in the Pervasive ODBC
driver.
To be sure you'll have to attach a debugger to the process and check which
thread is waiting
and what he is waiting for.
Another option is to get a copy of process explorer (procexp.exe) from
www.syinternals.com
(now on msdn) and watch the offending process threads and their stacks.

Willy.
Thanks for the reply;

I downloaded Process Explorer and This is what it shows for the program.

There are 3 threads of note: I have a BMP screen shot if you need to see
what else is there. It's to large to post however.

!GetMetaDataPub licInterfaceFro mInternal+0xd30 --Wait:DelayExecu tion

Two others:

!l_RpcBCacheFre e+0x5b8 --Wait: WrLpcReceive

!l_RpcBCacheFre e+0x5b8 --Wait: WrLpcReceive

All the rest say Wait: UserRequest

I haven't a clue what all this means but hopefully you or somebody else
does.

Thanks

Edwin

Feb 27 '07 #9
"Edwin Smith" <sm**********@a ol.comwrote in message
news:u5******** ******@TK2MSFTN GP06.phx.gbl...
>
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:OL******** ******@TK2MSFTN GP05.phx.gbl...
>"Edwin Smith" <sm**********@a ol.comwrote in message
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>>
"Bruce Wood" <br*******@cana da.comwrote in message
news:11****** *************** *@q2g2000cwa.go oglegroups.com. ..
On Feb 25, 9:15 pm, "Edwin Smith" <smithgold...@a ol.comwrote:
I have a form which displays a DataGridView table generated with the
VS2005
tools. The database is a Pervasive v.9 with an ODBC driver.
>
The DataGridView works great except when I'm done and I click the X to
close
the form the .exe refuses to die and has to be killed in Task manager.
>
I ran a debug trace and it seems to work fine. I dropped a CLOSE button
onto
the form and put "this.Close ();" in for it's event but I get the same
result.
>
Using trial/error troubleshooting seems to point to some of the
generated
code behind the TableAdapter. If I comment it out the form closes
properly
but then of course my DataGridView doesn't work.
>
Anyone have a similar problem?
>
I'm also having a VS2005 lockup problem (on another thread) which may
or may
not be related.
>
My next step is to start over from scratch since it's fairly easy to
rebuild
once I have screenshots of my queries etc...

This sounds like a background thread that isn't marked "background ".
The application shuts down only when all foreground threads have
stopped executing. If your code starts a background thread to do some
long-running task (like fetching data from a database) and doesn't
mark the thread "IsBackgrou nd", then the thread will keep your
applicatio n alive.

You'll have to find the code that starts the background thread and
ensure that the thread's IsBackground property is set to true.
Does the code generator for the TableAdapter.Fi ll generate background
threads for ODBC
connections ? Since this is filling a DataGridView table it DOES get the
entire table in
memory before it displays the form. Then it disconnects from the
database. ( I think)

Or is the background thread just an automagic thing and I have to insert
the IsBackground
property somewhere in order for the code to shutdown properly?

I searched the entire project and the text "IsBackgrou nd" does not
appear anywhere.

AFAIK this project runs in a single thread since I have not explicetly
set anything for
multithread ed operation. I'm not that sophisticated a programmer yet so
multithreadin g is
way over my head.

Thanks

Edwin


In this case it means that the code is stucked (or deadlocked) in the main
thread (are you
sure your Main is marked STAThread ?), probably in the Pervasive ODBC
driver.
To be sure you'll have to attach a debugger to the process and check which
thread is waiting
and what he is waiting for.
Another option is to get a copy of process explorer (procexp.exe) from
www.syinternals.com
(now on msdn) and watch the offending process threads and their stacks.

Willy.

Thanks for the reply;

I downloaded Process Explorer and This is what it shows for the program.

There are 3 threads of note: I have a BMP screen shot if you need to see what else is
there. It's to large to post however.

!GetMetaDataPub licInterfaceFro mInternal+0xd30 --Wait:DelayExecu tion

Two others:

!l_RpcBCacheFre e+0x5b8 --Wait: WrLpcReceive

!l_RpcBCacheFre e+0x5b8 --Wait: WrLpcReceive

All the rest say Wait: UserRequest

I haven't a clue what all this means but hopefully you or somebody else
does.

Thanks

Edwin

Hard to tell where these threads come from, all I can say is:
- the first thread is waiting for a timer interrupt.
- the next two threads are waiting on a synchronization object, if both are waiting on the
same object, they could be deadlocked.
None of these threads are the application's UI thread, nor are they CLR threads, so my guess
is that they come from a buggy ODBC driver.

Q. Are you running this in the VS debugger? If yes, what happens when you run stand-alone?
Q. Are you sure the process don't go away after a time-out?

Willy.
Feb 27 '07 #10

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

Similar topics

3
2850
by: Andreas | last post by:
Hi, I just created my first vb.net pocket pc application - that consists of a main dialog and an additional dialog that is defined globally like this: Dim x as New MyTestDialog As the dialog's constructor takes a lot of time to do all that is necessary, it is called only one time when the process starts - and I just call ShowDialog any time I need to display it to the user.
6
2188
by: gizmo | last post by:
I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word). My problem is that I need to kill each instance individually, but this does not appear possible using the Process object. When I run the example below the process object "p" can be viewed using Quick Watch however process object p2 is displayed as undefined, with the added affect of not...
5
7330
by: Brett | last post by:
How do I gracefully kill a process than restart it? The process Image Name is known. Thanks, Brett
0
2255
by: henning.friese | last post by:
Hello NG, I'm need to write some code which creates tiff files from various document types (doc, pdf, xls). I want to do this by ShellExecuting (via System.Diagnostics.Process) the doc-files with the "print"-verb. This works for me. However, I need to handle the case when a printing application doesnt't quit in a given timespan (for example a password-protected word-document). So I've tried the following:
4
32806
by: Andy | last post by:
I am calling out to an executable using the System.Diagnostics.Process methods and specifically attempting to trap for errors (at least trying to learn how to trap for errors). I arranged the data to specifically error when calling this executable. System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = "intupld.exe"; process.StartInfo.Arguments = hupFile; process.StartInfo.WorkingDirectory =...
2
5124
by: David | last post by:
I'm opening a cmd window to run an ftp process. It's easy enough to close the process (.close()), but the cmd window won't close unless I go out to the window and type 'quit'. How can I send a request to the cmd window to close? Here's the code snippet that I'm using to make the call: string strArg = "/c ftp.exe -v -n -s:" + strFile + " " + strHost + " > " + strLogFile;
16
2157
by: Caroline | last post by:
I am building a web application to gather user information then launch a process to calculate results. The process is a 3rd Party executable. I cannot get the process to start. Is there a problem with this code? Public Overloads Shared Function StartApplication(ByVal fileName As String, ByVal myPath As String) As Process Try Dim WtDistrib As New Process WtDistrib.StartInfo.Verb = "Execute" WtDistrib.StartInfo.CreateNoWindow = True
3
5160
by: Brad | last post by:
In a Vista/IIS7 asp.net app, a coded crystal report export is crashing IIS7....but it works just fine in visual studio's cassini web server. And if I create a web form and use the crystal reports web viewer, view the report and then export from the viewer it also works fine (IIS7 and cassini). And I should note this all works fine in IIS6 on win2003 or in xp. So my thought with all this is that something is going on with IIS7, so...
4
1463
by: =?Utf-8?B?U3Jhag==?= | last post by:
There is a process A that launches process B as a COM object. If the User tries to end process A, process B should also end. But vice versa is not true. Process A can run independant of process. It is not possible for a user to know process B is launched by process A. In the destructor of Process A, there is a code to close process B. During normal closing of process A, process B also gets closed. In certain situations this is not...
0
9546
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
10268
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
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
9079
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...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
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
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.