multithreading - Setting multiple values of 3 different labels via cross threading c# winforms -
so got code runs on usb connect event. if , android device detected runs build prop related code. however... manages return android version , nothing else. code below.
private void main_shown(object sender, eventargs e) { var watcher = new managementeventwatcher(); var query = new wqleventquery("select * win32_devicechangeevent eventtype = 2"); watcher.eventarrived += new eventarrivedeventhandler(watcher_eventarrived); watcher.query = query; watcher.start(); } private void watcher_eventarrived(object sender, eventarrivedeventargs e) { process process = new system.diagnostics.process(); processstartinfo startinfo = new system.diagnostics.processstartinfo(); startinfo.windowstyle = system.diagnostics.processwindowstyle.hidden; startinfo.redirectstandardinput = false; startinfo.createnowindow = true; startinfo.redirectstandardoutput = true; startinfo.redirectstandarderror = false; startinfo.useshellexecute = false; startinfo.filename = "adb.exe"; startinfo.arguments = "shell getprop ro.build.version.release"; process = process.start(startinfo); device.invoke((methodinvoker)(() => device.text = process.standardoutput.readtoend())); process p = new system.diagnostics.process(); processstartinfo si = new system.diagnostics.processstartinfo(); si.windowstyle = system.diagnostics.processwindowstyle.hidden; si.redirectstandardinput = false; si.createnowindow = true; si.redirectstandardoutput = true; si.redirectstandarderror = false; si.useshellexecute = false; si.filename = "adb.exe"; si.arguments = "shell getprop ro.product.model"; p = process.start(si); av.invoke((methodinvoker)(() => av.text = process.standardoutput.readtoend())); process pr = new system.diagnostics.process(); processstartinfo siy = new system.diagnostics.processstartinfo(); siy.windowstyle = system.diagnostics.processwindowstyle.hidden; siy.redirectstandardinput = false; siy.createnowindow = true; siy.redirectstandardoutput = true; siy.redirectstandarderror = false; siy.useshellexecute = false; siy.filename = "adb.exe"; siy.arguments = "shell getprop ro.product.name"; pr = process.start(siy); name.invoke((methodinvoker)(() => name.text = process.standardoutput.readtoend()));
this should returning 3 values , placing them respective labels. 1 returned. there way can improve code this? , shell getprop ro.*
worked in earlier build , had not been changed...
turns out being derp. had same process set , threw errors. rookie mistake really. got caught in own hype... new code
process process = new system.diagnostics.process(); processstartinfo startinfo = new system.diagnostics.processstartinfo(); startinfo.windowstyle = system.diagnostics.processwindowstyle.hidden; startinfo.redirectstandardinput = false; startinfo.createnowindow = true; startinfo.redirectstandardoutput = true; startinfo.redirectstandarderror = false; startinfo.useshellexecute = false; startinfo.filename = "adb.exe"; startinfo.arguments = "shell getprop ro.build.version.release"; process = process.start(startinfo); device.invoke((methodinvoker)(() => device.text = process.standardoutput.readtoend())); process p = new system.diagnostics.process(); processstartinfo si = new system.diagnostics.processstartinfo(); si.windowstyle = system.diagnostics.processwindowstyle.hidden; si.redirectstandardinput = false; si.createnowindow = true; si.redirectstandardoutput = true; si.redirectstandarderror = false; si.useshellexecute = false; si.filename = "adb.exe"; si.arguments = "shell getprop ro.product.model"; p = process.start(si); av.invoke((methodinvoker)(() => av.text = p.standardoutput.readtoend())); process pr = new system.diagnostics.process(); processstartinfo siy = new system.diagnostics.processstartinfo(); siy.windowstyle = system.diagnostics.processwindowstyle.hidden; siy.redirectstandardinput = false; siy.createnowindow = true; siy.redirectstandardoutput = true; siy.redirectstandarderror = false; siy.useshellexecute = false; siy.filename = "adb.exe"; siy.arguments = "shell getprop ro.product.name"; pr = process.start(siy); name.invoke((methodinvoker)(() => name.text = pr.standardoutput.readtoend()));
Comments
Post a Comment