vb.net - How do i link Visual Studio applications over LAN -
i have created vs application , have installed copy on computer , wish link them via lan if settings
canged in 1 , others setings saved .
for example setting
i created new name
in sttings , call "adminin" , set type integer
, scope
user
, set value 0
dim ai new .mysettings private sub button1_click(sender object, e eventargs) handles button1.click ai.adminin = ai.adminin + 1 ai.save() end sub
now how can ai updated in other application on other computer .
how connect via lan , accomplish ?
i found link provides example code modify application-scoped variables my.settings
might useful. i've tested out simple form timer , label showing me current value of adminin
setting, , seems work. timer updates label on every instance of form checking reloaded my.settings
value. variable need application scoped in order accessible users on machine may run executable.
http://www.codeproject.com/articles/19211/changing-application-scoped-settings-at-run-time
here's form code put keep current admin count up-to-date. simplistic, seems job neatly.
public class form1 private sub form1_formclosing(byval sender object, byval e system.windows.forms.formclosingeventargs) handles me.formclosing 'decrement adminin count when current instance of form closed. me.tmradmincheck.stop() changemyappscopedsetting((my.settings.adminin - 1).tostring) 'reload .exe.config file synchronize current adminin count. my.settings.reload() my.settings.save() end sub private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load 'increment current adminin count when new instance of form loaded changemyappscopedsetting((my.settings.adminin + 1).tostring) 'reload .exe.config file synchronize current adminin count. my.settings.reload() my.settings.save() me.lbladminsin.text = "current admins in: " & my.settings.adminin.tostring 'start timer periodically check adminin count my.settings me.tmradmincheck.enabled = true me.tmradmincheck.interval = 100 me.tmradmincheck.start() me.refresh() application.doevents() end sub private sub tmradmincheck_tick(byval sender system.object, byval e system.eventargs) handles tmradmincheck.tick 'reload .exe.config file synchronize current adminin count. my.settings.reload() me.lbladminsin.text = "current admins in: " & my.settings.adminin.tostring me.refresh() application.doevents() end sub end class
i've found couple of things method, , relate others have mentioned in comments:
- the application's .exe.config file must in accessible location (the codeproject example defaults application's executable directory). of course, save settings ini file or other configuration file in shared directory , accomplish similar thing, method uses
my.settings
. - you'll may want additional checking possibility of 2 people attempting in @ same time. if happens, configuration file still open , locked, , new
adminin
value won't saved. codeproject example doesn't have exception handling, work functionality exception handling making recursive call sub.
otherwise, seems totally viable method of accomplishing you're talking about.
Comments
Post a Comment