vb.net - Using Thread Moving Files from PC to Remote Device -
using rapi2 send file pc remote device.
when using line without threads, works fine:
remotefile.copyfiletodevice(pdtremotedevice, "c:\sample.txt", "\test\sample.txt", true) but when try put line above inside thread, returns error device not connected.
how use rapi2's copyfiletodevice using thread?
not using thread make application looks hanged. so, don't think user appreciate application says not responding.
my code:
imports system.devices imports system.devices.remotedevicemanager public class formhome dim pdtremotedevice remotedevice dim devicemanager new remotedevicemanager private sub buttonhomecopytodevice_click(byval sender system.object, byval e system.eventargs) handles buttonhomecopytodevice.click pdtremotedevice = devicemanager.devices.firstconnecteddevice if pdtremotedevice nothing messagebox.show("no device connected, please try again") exit sub else dim th thread th = new thread(addressof uploaddatabase) th.isbackground = true th.start() end if end sub private sub uploaddatabase() using pdtremotedevice = devicemanager.devices.firstconnecteddevice if not (pdtremotedevice nothing) remotefile.copyfiletodevice(pdtremotedevice, "c:\sample.txt", "\test\sample.txt", true) end if end using end sub end class
try , let me know if works:
private sub uploaddatabase() using rdm new remotedevicemanager using d remotedevice = rdm.devices.firstconnecteddevice if not (d nothing) remotefile.copyfiletodevice( _ d, "c:\sample.txt", "\test\sample.txt", true) end if end using end using end sub
Comments
Post a Comment