big.nerd
New member
- Joined
- Feb 20, 2014
- Messages
- 3
- Programming Experience
- 10+
Hello All,
I will have to admit I am new (not only here, but to VB.NET) and I am working on a small purpose built app.
Essentially - it's a front-end to allow one of my customers to make certain changes to our MySQL Database, everything is working as expected, however I have now come to require an SSH Tunnel.
I've already used SSH.NET and was able to get the tunnel created, connect to mysql, execute query, etc..
I am looking for what the best practices is for keeping the tunnel open during the duration of the application.
For instance - right now I have assigned the code under a button - it creates the tunnel, connects, etc.
Rather than modifying the numerous points in the code where specific queries are performed to check if the tunnel is required, create, then continue with what is already done and working, I wanted to have the tunnel connected while the application is open.
My first instinct is to create a Background Worker, with the BackgroundWorker object sitting at class level (as per recommendation from Microsoft), as well as the client and portforward object for the SSH tunnel which should allow me to access it throughout the class, including checking if it's active, etc.
I guess .. so I stop rambling, what would be the best practice for executing this type of action? Am I on the right track with creating a background worker so it will continue to "wait" while other actions are performed, etc?
Thanks in advance for any advice anyone can give .. code of course is always appreciated but I would like to learn the best possible way, so looking for advice.
I will have to admit I am new (not only here, but to VB.NET) and I am working on a small purpose built app.
Essentially - it's a front-end to allow one of my customers to make certain changes to our MySQL Database, everything is working as expected, however I have now come to require an SSH Tunnel.
I've already used SSH.NET and was able to get the tunnel created, connect to mysql, execute query, etc..
I am looking for what the best practices is for keeping the tunnel open during the duration of the application.
For instance - right now I have assigned the code under a button - it creates the tunnel, connects, etc.
Rather than modifying the numerous points in the code where specific queries are performed to check if the tunnel is required, create, then continue with what is already done and working, I wanted to have the tunnel connected while the application is open.
My first instinct is to create a Background Worker, with the BackgroundWorker object sitting at class level (as per recommendation from Microsoft), as well as the client and portforward object for the SSH tunnel which should allow me to access it throughout the class, including checking if it's active, etc.
I guess .. so I stop rambling, what would be the best practice for executing this type of action? Am I on the right track with creating a background worker so it will continue to "wait" while other actions are performed, etc?
Thanks in advance for any advice anyone can give .. code of course is always appreciated but I would like to learn the best possible way, so looking for advice.