PDA

Click to See Complete Forum and Search --> : app.previnstance


rothj0hn
Mar 15th, 2010, 04:33 AM
how to use app.previnstance(VB6) in vb.net 2008?

cicatrix
Mar 15th, 2010, 05:32 AM
If you want to create a single instance application just go to Project/Properties and check the 'Make single instance application' checkbox.
This way all attempt to run your application will result in activating of your running instance.

If you want to get the process of the running instance use:
Dim PrevInstances() As Process = Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)

The PrevInstances array will hold all the processes that has the name of your process.

jmcilhinney
Mar 15th, 2010, 08:08 AM
Instead of asking how to use a feature of VB6 in VB.NET when it doesn't exist, please explain what you're actually trying to achieve so we can explain how to achieve it.

rothj0hn
Mar 15th, 2010, 10:25 PM
i just want to run my application in single instance only.

jmcilhinney
Mar 15th, 2010, 11:12 PM
i just want to run my application in single instance only.

Then that's probably what you should have said. There is no App.PrevInstance in VB.NET so there is no way to use it. As suggested, it's a matter of checking the the appropriate box on the Application tab of the project properties. How certain functionality was achieved in VB6 is generally irrelevant because so much has changed in VB.NET. It's the actual functionality you're trying to achieve that matters. If you quote that then you can get help from people who've never used VB6 but know how to do it in VB.NET as well.

rothj0hn
Mar 16th, 2010, 02:15 AM
how bout in mobile application? cant find the check box..

jmcilhinney
Mar 16th, 2010, 02:34 AM
how bout in mobile application? cant find the check box..Given that there's a specific forum dedicated to .NET Mobile development, we won't assume that it's mobile if it's in this forum.

In that case, I'm guessing that you'd have to use the Process class to find existing instances, as cicatrix also suggested. There may be a better trick that mobile developers know, which is why you should post in the Mobile forum. I'll ask the mods to move this thread.

cicatrix
Mar 16th, 2010, 02:41 AM
I can be wrong, but doesn't all Windows Mobile applications are single-instance apps by default? I'm not sure whether my guess is correct but you can't have more than 1 instance of any app there.

si_the_geek
Mar 16th, 2010, 04:24 AM
Thread moved from 'VB.Net' forum to 'Mobile Development' forum

(thanks for letting us know jmcilhinney :thumb: )

petevick
Mar 16th, 2010, 06:20 AM
Hi,
Windows Mobile Applications do run single instance by the nature of the operating system.

JacquesLebrun
Apr 8th, 2010, 12:48 PM
I have the same problem on VB.NET 2008 on Windows Mobile 5.0 and I fail to find a solution.

1) Windows Mobile does not force a single instance of an application. If I double click on my program ICO twice, and then look at the task list, I see two programs.

2) I tried to access the process but I could not find any commands to find a process in Windows Mobile (normal VB.NET like GetProcessByName do not exist).

3) I tried to use a Mutex with the followinf code, but it never detects duplicate instances:

Dim objMutex As New Mutex(True)
If objMutex.WaitOne(0, False) = False Then
MsgBox("Duplicate instance")
objMutex.Close()
objMutex = Nothing
Me.Close()
End If

Has anyone managed to find a way to prevent duplicate instances in a Windows Mobile Device?

petevick
Apr 9th, 2010, 03:02 AM
Windows Mobile does (normally) force a single instance.

Try setting up a test application, with just one form. Start it, back to explore, double-click again and your application gets the focus. Run Taskmgr and you will see only one instance.

Let us know your results please.

JacquesLebrun
Apr 13th, 2010, 07:33 AM
Sorry for the delay, I had to release a BETA version of my program for my customer.

I started a new Mobile application using VB.NET 2008:
- New Project -> Smart device -> Smart device project
- Target platform: Windows Mobile 5.0 PocketPC SDK
- Compact framework version: 3.5
- Template: Device application

I only but a textbox with "hello" on the form, compiled it, and moved the executable to the PocketPC. If I double-click on the program twice, I get two instances of my program in the TaskMgr.

What I am doing wrong?

petevick
Apr 13th, 2010, 10:45 AM
What is your target device?

JacquesLebrun
Apr 13th, 2010, 12:00 PM
It is called MobileBase.

Settings -> System:

- General tab:
Microsoft Windows CE
Version 5.00 (Build 1400)
Processor: Marvell, Xscale/ARM11-PXA320
75120 Km RAM

- Memory tab:
Storage memory: 32864Kb total, 6980Kb in use
Program memory: 42256Kb total, 11328Kb in use

- Device name tab:
Device name: WindowsCE
Description: WindowsCE Device

Settings -> Version:

Boot tab:
Customer: MERG
HW: 06C
SW: 120
Date: 100119
Model: 7KPNAN128256ENG

OS tab:
Customer: MERG
HW: 06C
SW: 120
Date: 100119
Model: 7KPNAN128256ENG
WinCE: 50
Language: E

App tab:
MB_WLANPower.exe 1.0.0.2

petevick
Apr 14th, 2010, 02:03 AM
So it is a Windows CE Device, not a Windows Mobile (PocketPC) device.

http://bitmatic.com/csharp/single-instance-applications-in-windows-ce