Results 1 to 10 of 10

Thread: Environment Process Variables question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2014
    Posts
    70

    Environment Process Variables question

    I'm building an application which sets some process Environment Variables and then launches another application which can read the value's of these variables. I'm wondering, If I update the Environment variables via my app is there a way that the child application can read the update values without having to close it down and relaunch from my application each time.
    Last edited by blothian; Mar 11th, 2015 at 05:03 PM.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,677

    Re: Environment Process Variables question

    This sounds like how events are used:
    Code:
    Private _foo As String
    Public Property Foo() As String
        Get
            Return _foo
        End Get
        Set(ByVal value As String)
            If _foo <> value Then
                _foo = value
                Me.OnFooChanged()
            End If
        End Set
    End Property
    
    Protected Overridable Sub OnFooChanged()
        RaiseEvent FooChanged(Me, EventArgs.Empty)
    End Sub
    
    Public Event FooChanged(ByVal sender As Object, ByVal e As EventArgs)
    See how when the property Foo changes it calls a method to raise the event FooChanged? You will need to do a similar concept.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,443

    Re: Environment Process Variables question

    Quote Originally Posted by blothian View Post
    is there a way that the child application can read the update values without having to close it down and relaunch from my application each time.
    Any application can read any environment variables any time it wants. If the application is not yours though, and it has been coded to only read the environment variables when it starts up, it should be obvious that the only way to have it read new values is to start up again. You can't magically make an application do something that it hasn't been programmed to do. So, is this child app your creation? If not then you have to live with what its author provided. Does that author provide a means to tell the app to reread environment variables? If they do then avail yourself of that feature but, if not, then you must use the only means available to make it read environment variables, i.e. start it.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2014
    Posts
    70

    Re: Environment Process Variables question

    Quote Originally Posted by jmcilhinney View Post
    Any application can read any environment variables any time it wants. If the application is not yours though, and it has been coded to only read the environment variables when it starts up, it should be obvious that the only way to have it read new values is to start up again. You can't magically make an application do something that it hasn't been programmed to do. So, is this child app your creation? If not then you have to live with what its author provided. Does that author provide a means to tell the app to reread environment variables? If they do then avail yourself of that feature but, if not, then you must use the only means available to make it read environment variables, i.e. start it.
    No the child application isn't my creation and I agree with what you say as its what I was thinking but I wasn't 100% sure and posted in case there was something way of achieving it that I didn't know. As you say it can't magically do it but I can speak with its developer's technical support and see if they have any way of being able to reread the environment variables. Thanks for the clarification.

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,443

    Re: Environment Process Variables question

    Assuming that you do end up needing to restart the app, do you know how to do that? If you need instruction, please let us know whether it has a GUI or not.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2014
    Posts
    70

    Re: Environment Process Variables question

    The app is essentially a simple launcher, To date in testing I've kept it running in the background whilst the child app is running. I've just tested closing down the child app and changing the selections 2No. combobox's on the form (which is how I set the 2no. Process EV's) and relaunched the child app. I've tested and found the child app will read the revised values without having to close the parent app so at least that's something. This might actually be the best solution from a user operation perspective so I will probably proceed with this functionality from here on in. Thanks for the offer of assistance, as a .NET noob it's really appreciated.

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,443

    Re: Environment Process Variables question

    When I said "restarting the app" I meant the child app. Of course there's no reason to restart the launcher. Are you starting and restarting the child app from code in the launcher? If so, how? Just ignore this if you are happy with what you're doing now but if you aren't or are not sure then let us know what you're doing we'll tell you if it can be improved.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2014
    Posts
    70

    Re: Environment Process Variables question

    Nah I'm just closing the child via the exit button or file menu\exit, no need to do it via the launcher.

  9. #9
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,443

    Re: Environment Process Variables question

    Quote Originally Posted by blothian View Post
    Nah I'm just closing the child via the exit button or file menu\exit, no need to do it via the launcher.
    But why not do it in code from the launcher when you change the environment variables? That seems the logical thing to do to me.

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Aug 2014
    Posts
    70

    Re: Environment Process Variables question

    The best reason would be is that's what's most intuitive for users who are used to working with the child app. They would normally close files opened with this child app using the File\Exit,Exit or alternatively using File\Close(if they wanted to close the currently opened file and revert to the child apps in-built file manager. Closing it in code from the parent app would likely add some level of confusion which I'm aiming to keep to a minimum because introducing my app into the workflow is something users will need to adapt to.

    Perhaps if I explain the app's purpose it might clarify things. My job is as a CAD/BIM Manager. Currently my app consists of a single form with 2 comboxes which are populated from text files (it will develop more functionality eventually). The first CB reads a text file which contains all the name of Clients for that office and the second combobox looks for a text file in a specific location that uses the clients name as the filename with a .txt suffix. Its contents on each line of this file are the project names relating to that client. When a selection is made in either CB it sets the values of for the process EV's (called Client and Project). I've then got a button that loads the child app. The child application is a 3D/2D modelling software which can be configured by reading text files to set program-specific configuration variables during its loading sequence (as well as reading process variables as you stated earlier) using the syntax VARIABLE = PATH AND\OR FILENAME. What my app will allow is to preset the project and client and have the child app load the correct settings for that client and project.

    I see you are from Australia but my knowledge of Aussie companies is fairly limited but I'll cook up a simple fictional example of how this all comes together. If I was doing drawings for a new brewery in Melbourne(Project) for Victoria Bitter(Client), I can ensure that the logo for that projects drawings title block doesn't use the logo on the titleblock for the new Toohey's Brewery in Sydney. If I then had to do some work on an extension to the Coopers Brewery in Adelaide, I would exit the current drawing I was in thus closing the child app and return to the launcher, change the client to Coopers and change the project to Adelaide Extension. So when I load the child app again all the correct settings for Coopers and the Adelaide job are loaded (because there may well be settings that are different from one Coopers job to another)

    Thats probably more long-winded that it needed to be but I'm aware that my extensive knowledge of the child app and its configuration methods are not known to yourselves whereas the VB.NET expertise is your area and that is what I'm trying to improve upon.

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