Background Task

Discussion in 'Questions (Windows Mobile)' started by RandomCoder, Jun 27, 2008.

  1. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I've searched the Forum but not found anything relating to running programs in the background on the desktop.
    I'm writing a backup utility (primarily for a friend) using the ROBOCOPY function and what I would like to do is, after a preset time backup to a USB drive when it connects to the PC.
    Agraham has assisted with the http://www.basic4ppc.com/forum/questions-help-needed/2606-drive-detection.html , but this is no good unless I can actualy force the App to run in the background.
    At best I would have to use SHELL to issue an AT command to schedule ROBOCOPY to run, but then I remove the possibility of detecting the drive presence first.
    I don't think that running with the form minimised is really a solution as it would be displayed on the task bar all the time.

    Got any ideas?

    @Erel, any plans to make B4PPC stay active even if no FORM is displayed, maybe as an option within the tools menu?

    Thanks,
    RandomCoder
     
  2. dzt

    dzt Active Member Licensed User

  3. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Thanks DZT but thats not quite what I was after, but it's going to come in handy.

    I'd like to have my app running completely in the background. The taskbar icon is good as it will allow the user to select options such as to close the App. But the problem is that the form is still minimized on the taskbar when run on the desktop.

    I suppose what I'm after is to close the Form but keep the code running. Does that make sense? Think of it as a service in XP.

    Regards,
    RandomCoder
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    On the device you can set the form's title to "" (empty string), and use Hardware.ShowTodayScreen.
     
  5. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I realise that is possible on the device but my question is only related to the desktop.
    Am I just trying to use B4PPC for something it was never intended?
    Any work around would be greatly appreciated.

    Thanks,
    RandomCoder.
     
  6. agraham

    agraham Expert Licensed User

    Check out this utility http://www.basic4ppc.com/forum/code-samples-tips/1222-reminder-utility.html It does what you want by using a FormEx from my FormExDesktop library, which has a Hide method that removes it from the taskbar, and a NotifyIcon from my ControlsExDesktop library.

    dzts' library might work as well but I haven't tried that as I've got my own :)

    EDIT :- I've just tried this. You could also use the Door library on a normal Form and hide that using its' visible property, unhiding it from the NotifyIcon Click event.
    Code:
    ' o is a Door library object
    o.new1(false)
    o.FromControl(
    "Form1")
    o.SetProperty(
    "Visible"false)
     
    Last edited: Jun 27, 2008
  7. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Agraham to my rescue again :)

    I had a feeling that the door library would be suggested but didn't know what properties were possible. Where do you find this information? MSDN is immense and often what I want to find is scattered across the site (but saying that, I managed to find the Windows message for DeviceAdded to see where you got those values
    from).

    Thanks for the help once again, this is exactly what I'm after.

    Regards,
    RandomCoder
     
  8. agraham

    agraham Expert Licensed User

    See this post http://www.basic4ppc.com/forum/11133-post16.html Most of what is useful for controls in B4ppc is in Systems.Windows.Forms. Arcane stuff, especially if it is not .NET like DeviceAdded, you either have to already know or Google for.
     
  9. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Thanks for the heads up, already added to my bookmarks, with a little searching I was able to find this Form Properties (System.Windows.Forms) listing all the properties for a Form.
    MSDN is not the easiest of sites to navigate especially if your not entirely sure of the exact terminology to use.

    Cheers,
    RandomCoder
     
  10. klaus

    klaus Expert Licensed User

  11. RandomCoder

    RandomCoder Well-Known Member Licensed User

    This is a fantastic utility for beginners and intermdiates like myself.
    I've added a shortcut link in my B4PPC startup folder so thats its easily accessible when I need it.

    But can I ask, what is a namespace?
    I refer specifically to this MSDN article NotifyIcon Class (System.Windows.Forms) about the notify icon.
    I'm interested in knowing how the notifyicon is linked to the Form. Can it be done with the door library? I'm presuming that it can't as it is not listed in either the methods or properties of the Form and so presumably it's what I would call a stand-alone function that effectively bolts on to the Form which is why I must use either Agraham's or DZT's library.
    Sorry if this appears a silly question but I'm trying to better understand how all the bits and pieces tie together not just for B4PPC but also in VB.

    Thanks,
    RandomCoder
     
  12. agraham

    agraham Expert Licensed User

    All .NET classes (objects) live in a namespace, the biggest of these is probably System. You can regard namespaces as a hierarchy, a bit like a folder tree. The namespace in which a class lives is part of the class name so that classes of the same name can be defined in different namespaces without conflict. For example there is a Button object in both System.Windows.Forms and System.Web.UI.WebControls namespaces. You define the namespaces you want to use when writing code. In VB this by "Imports". Then you don't need to use the fully qualified name including the namespace when referring to classes unless there is a conflict. For example if I want to define a Class in a library called "Button" that will be in a namespace I choose and will be the default namespace when the compiler wants to find Button. If I then want to use System.Windows.Forms.Button then that is how I refer to it so the compiler knows it is not my Button I want.

    Form, NotifyIcon, Button etc. are all Controls. Controls are linked in a hierarchy with, usually, a Window (Form) at the top. A NotifyIcon would be a Child of a Form, the Form being the Parent of the NotifyIcon. Each Control has a Parent property identifying its Parent control and a Controls collection identifying its Child controls. A Control is assigned to a Parent by using the Controls.Add method of its Controls collection - this takes care of unassigning any previous Parent control and assigning the control to the new.

    You probably could create a NotifyIcon and add it to a Form using the Door library but accessing its methods and properties would be a bit long winded - its much easier to encapsulate it in a library.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice