473,383 Members | 1,735 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,383 software developers and data experts.

2kPro + .Net + HyperThreading = Bizarre Issue?

I was recently set to release an app that used very common single instance
code and hit the oddest issue.

After many hours of full build tests I believe that it is duplicatable.

Environment:

..Net 1.1 (v1.1.4322)
Windows 2000Pro
HyperThreading machine

Issue:

Install 2kPro on the HT box (I use an MSI-based 3.06Ghz), fully install all
Windows Updates.

Create a .Net app using the single instance code based on
Diagnostics.Process.GetProcessesByName(Diagnostics .Process.GetCurrentProcess
..ProcessName)

Install the application on the 2k box & run it.

If the code is called in the Load even to a form you will get a "Couldn't
get process information from remote machine" exception. The exception dump
will mention not being able to get the process "ticks"

If the same code is called from a sub main rather than from a form_load then
you will get an "Unhandled Exception occurred" error.

Now, here's where it gets weird: Restart the machine and get into the BIOS.
Disable Hyperthreading and get back into Win2k. Run the app. It runs fine.
Minimize it and try to start a second instance and the first instance pops
up to the top of the order and the second instance dies. Perfect.

Now, restart and go back into the BIOS and turn HT back on. Get back into
Win2k. Run the app. It runs fine in every way.

NOW: Go back into the BIOS and turn HT back on. Get Back into Windows and
run the app. It Runs Fine.

Wierder still: Uninstall the application, search the machine and make sure
that it's gone. Restart the computer. Reinstall the app (Hyperthreadin
still ON). Run the app. It runs fine!

Format the drive and fully reinstall Win2k Pro then the app. It starts all
over again.

I could understand this if the app continued to run after turning HT back on
the first time ... from my level of understanding that could be because
without HT the code could fully execute and so it got compiled for the
machine and later with HT turned back on the code was already compiled.

But why is it that after uninstalling the app fully, and just reinstalling
the app "fresh" the code runs? (And, another test app using the same code
also now runs)

XP Home and Pro have no such issue with the code with or without
Hyperthreading, it's just 2k.

I've seen a couple of mentions of the "Couldn't get process information from
remote machine" exception related to HT, but none of these few say anything
about switching HT off then on again as a fix.

Here is one of the few mentions:

http://groups.google.com/groups?hl=e...%3D10%26sa%3DN
Can a framework or lower-level expert shed some light on why all this might
be? I'd love to hear the logic.

(I'm converting the code to use a Mutext because it appears the crux of the
matter is in the use of GetCurrentProcess.ProcessName)
Fyi: here is the code, it is fairly common:

''Declarations: (excuse the "straight style", it is for this test)

Public Const SW_NORMAL = 1
Public Const SW_MAXIMIZE = 3
Public Const SW_RESTORE = 9
Public Const HWND_TOP = 0
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1

Declare Function ShowWindow Lib "user32" (ByVal hwnd As Integer, _
ByVal nCmdShow As Integer) As Integer

Declare Function ShowWindowAsync Lib "user32" (ByVal hwnd As Integer, _
ByVal nCmdShow As Integer) As Integer

Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Integer

Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, _
ByVal hWndInsertAfter As Integer, ByVal x As Integer, _
ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, _
ByVal wFlags As Integer) As Integer
Sub main()
If HasPrevInstance() Then
Exit Sub
Else
Dim fMain As New Form1
fMain.ShowDialog()
End If
End Sub

Private Function PrevInstance() As Boolean
If

Diagnostics.Process.GetProcessesByName(Diagnostics .Process.GetCurrentProcess
..ProcessName).Length > 1 Then
Return True
Else
Return False
End If
End Function

Private Function HasPrevInstance() As Boolean
If PrevInstance() = True Then
' Get all previous instances
Dim Processes() As Process
Processes =
Diagnostics.Process.GetProcessesByName(Diagnostics .Process.GetCurrentProcess
..ProcessName)
' Activate the first instance
Dim temphwnd As Integer
Dim x As Integer
Try
For i As Integer = 0 To Processes.Length - 1
temphwnd = Processes(i).MainWindowHandle.ToInt32
x = ShowWindowAsync(temphwnd, SW_RESTORE)
'bring it to the top of the z-order
SetWindowPos(temphwnd, HWND_TOPMOST, 0, _
0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)

SetWindowPos(temphwnd, HWND_NOTOPMOST, 0, _
0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
Next

Catch ex As Exception
'Todo: Replace for release
MsgBox(ex.ToString)
End Try
Return True
Else
Return False
End If

End Function
-robert smith
kirkland, wa

Jul 21 '05 #1
1 1671
Oh, not "unhandled exception" but one of those fun "UnHandle-Able"
exceptions :) I'll spend the 3 hours again resetting the machine (again)
and wrap in a try...catch, might get the "remote machine process" exception
that way.

(and before you disqualify the whole: "mutex", sorry <g>)

But the question remains valid.

-s
Previous

Jul 21 '05 #2

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

Similar topics

1
by: BlackHawke | last post by:
Hello! I have a java application (a game) which is supposed to run as a server. It is on a dedicated machine with MP capabilities, but currently running 1 Xeon processor with hyperthreading. ...
5
by: Garry Hodgson | last post by:
a colleague of mine has seen an odd problem in some code of ours. we initially noticed it on webware, but in distilling a test case it seems to be strictly a python issue. in the real system, it...
0
by: octaviansen | last post by:
Hi, I am experiencing some weird problems with an ASP.NET web application that is making use of System.Data.DataSet and System.Data.DataRow classes. On a machine with single CPU, the...
4
by: Firdousi Farozan Z | last post by:
Hi All, I have a Java multithreaded application, that makes several JNI calls (native code written in C++). I use database locks all through the C++ code for synchronization. With...
0
by: GeorgeB | last post by:
HI, I created an ASP.NET application which runs on win 2003 server and IIS6 with hyperthreading enabled. I keep getting the following error: Path: /Login.aspx. Source: System.Web at...
6
by: Param - Home | last post by:
Hi all, we are in the process of getting a new server and wanted to know whether it is worth getting a dual cpu or just a single cpu like a p4 3ghz with hyperthreading? How does asp.net web...
1
by: Joe Jax | last post by:
I am developing an ASP.NET app using VS.NET 2003 on a P4 based desktop. Most every time I run the app from VS.NET the web page comes up with 'Action Canceled', and I have to hit refresh to...
1
by: smith | last post by:
I was recently set to release an app that used very common single instance code and hit the oddest issue. After many hours of full build tests I believe that it is duplicatable. Environment: ...
1
by: smith | last post by:
I was recently set to release an app that used very common single instance code and hit the oddest issue. After many hours of full build tests I believe that it is duplicatable. Environment: ...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.