Results 1 to 16 of 16

Thread: app.previnstance

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    app.previnstance

    how to use app.previnstance(VB6) in vb.net 2008?

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: app.previnstance

    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:
    Code:
    Dim PrevInstances() As Process = Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)
    The PrevInstances array will hold all the processes that has the name of your process.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: app.previnstance

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: app.previnstance

    i just want to run my application in single instance only.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: app.previnstance

    Quote Originally Posted by rothj0hn View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    398

    Re: app.previnstance

    how bout in mobile application? cant find the check box..

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: app.previnstance

    Quote Originally Posted by rothj0hn View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: app.previnstance

    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.

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: app.previnstance

    Thread moved from 'VB.Net' forum to 'Mobile Development' forum

    (thanks for letting us know jmcilhinney )

  10. #10
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: app.previnstance

    Hi,
    Windows Mobile Applications do run single instance by the nature of the operating system.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  11. #11
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    263

    Re: app.previnstance

    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:

    Code:
            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?

  12. #12
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: app.previnstance

    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.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  13. #13
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    263

    Re: app.previnstance

    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?

  14. #14
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: app.previnstance

    What is your target device?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  15. #15
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    263

    Re: app.previnstance

    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

  16. #16
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: app.previnstance

    So it is a Windows CE Device, not a Windows Mobile (PocketPC) device.

    http://bitmatic.com/csharp/single-in...-in-windows-ce
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width