Results 1 to 5 of 5

Thread: [RESOLVED] Settings and power troubles

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Resolved [RESOLVED] Settings and power troubles

    I have been using this code for a while now on my development machine and it worked all the time. Now, my test machine is a laptop without a battery. When the laptop loses power and shuts down immediately, the next time it turns back on just fine but my program starts having issues while loading.
    Spare the, this isn't safe for the laptop, I know, but it's all I can do until I mod the power button.
    Anyways, the program acts like the settings were never there, never initialized, never contained properties, nothing. I added the try/catch block and every time I start the program it always enters the catch block.
    I am saving all the settings for the program every 15 seconds, but not closing the program is causing major problems. Is there anyway around this, or am I sol?

    Code:
    Try
                If My.Settings.firstresolution = "" Or My.Settings.firstresolution Is Nothing Then
                    My.Settings.firstresolution = "800x480"
                    resolution = "800x480"
                Else
                    resolution = My.Settings.firstresolution
                End If
            Catch
            End Try
    
    Try
                If My.Settings.SkinFolder Is Nothing Or My.Settings.SkinFolder = "" Then
                    My.Settings.SkinFolder = resolution & "\Default"
                    Form1.skinfolder = resolution & "\Default"
                Else
                    Form1.skinfolder = My.Settings.SkinFolder
                End If
            Catch
            End Try
    Last edited by detlion1643; Nov 15th, 2010 at 03:25 PM. Reason: Fixed code blocks

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Settings and power troubles

    If you are saving the settings before losing power, I am not sure why they would be missing when power is lost and then the machine is rebooted.

    The only thing I can think you might want to try is to uncheck the option to "save my.settings on shutdown" which can be found in the project properties -> application tab. Maybe having that option checked is causing the problem when power is lost.

    Of course the power being lost to the OS is a pretty uncommon scenario. Even when a battery is running low, the machine will force sleep or hibernation when it can't function any further. Is it really a nessesity to code for that happening?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Settings and power troubles

    Normally I agree that it's a pretty uncommon scenario. In the situation I am in, I would normally standby/hibernate after a set period of ac power being lost if the laptop had a battery.

    I didn't really want to describe the situation, as it seems like a long one to describe but here goes:
    Laptop is in the car, no battery for laptop. Wires from +/- of car battery run to switches in the dash. From switches in dash, the +/- run to power inverter. From power inverter to laptop. When switches are on, laptop is manually turned on. When switches are off, laptop shuts off. I am in search of how to modify or jump the pins on the motherboard to simulate the press of the power button (this will solve the whole issue), but I am horrible with electrical work.
    So, in the meantime I shut the switches off and the laptop shuts off. I didn't code the settings to save just in case of this, but figured saving them wouldn't hurt anyways. I will try un-checking the save settings on shutdown as soon as I get home from work.

    Once the settings seem like they are corrupted, I can just build a new release and overwrite all the files and the new build will work just fine. I wonder if I am just getting unlucky in my timing, and losing power while it saves the settings corrupts them?

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Settings and power troubles

    why don't you exit the app before flipping the switch off?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Settings and power troubles

    That probably would be the easiest thing to do. I didn't leave room on the app because I didn't think I would need to close it, it's a full screen touch media player, meant to not close. I might have to hide a close button somewhere for the time being.

    Thanks anyways and I'll just go this route until I get the setup I am waiting for.

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