c# - Why does my Outlook becomes slow and sometimes unresponsive after starting an app to clear the clipboard? -
i had requirement disable copy paste , print screen key while website running. wrote wpf application keep clearing clipboard when open website link clicked , stop clearing close website button. problem when press open website button outlook client becomes slow , unresponsive. know has clipboard only. there way disable outlooks clipboard until button pressed.
however code not required included bleow, or can downloaded dropbox:
using system; using system.collections.generic; using system.linq; using system.text; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes; using system.security.cryptography; using mysql.data.mysqlclient; using system.threading; using system.net.networkinformation; namespace ccb { /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : window { string docnum,qs; int status = 0; static string connectionstring = "server=abcd.com;port=3306;database=abcd_secure;uid=abcd_sec;password=abcd_sec"; mysqlconnection conn = new mysqlconnection(connectionstring); private static random random = new random((int)datetime.now.ticks); public mainwindow() { initializecomponent(); } private string randomstring(int size) { stringbuilder builder = new stringbuilder(); char ch; (int = 0; < size; i++) { ch = convert.tochar(convert.toint32(math.floor(26 * random.nextdouble() + 65))); builder.append(ch); } return builder.tostring(); } private void button1_click(object sender, routedeventargs e) { status = 1; thread backgroundthread = new thread(clear); backgroundthread.isbackground = true; backgroundthread.setapartmentstate(apartmentstate.sta); backgroundthread.start(); qs=generaterandomnumber(); insert(qs); system.diagnostics.process.start("http://abcd/login.php?osid=win&id="+qs); } private void clear() { while (status == 1) system.windows.clipboard.clear(); } //genrate random number , encrypt md5 private string generaterandomnumber() { string rand1 = randomstring(8); string rand2 = randomstring(8); docnum = rand1 + "-" + rand2; md5 md5 = new md5cryptoserviceprovider(); md5.computehash(asciiencoding.ascii.getbytes(docnum)); //get hash result after compute byte[] result = md5.hash; stringbuilder strbuilder = new stringbuilder(); (int = 0; < result.length; i++) { //change 2 hexadecimal digits //for each byte strbuilder.append(result[i].tostring("x2")); } return strbuilder.tostring(); } //insert generated value database protected void insert(string q) { try { conn.open(); string ins = "insert mgen_validation_check(md5values) values(@m)"; mysqlcommand cmd = new mysqlcommand(ins, conn); cmd.parameters.addwithvalue("@m", q); cmd.executenonquery(); } catch (exception ex) { } { conn.close(); } } private void button2_click(object sender, routedeventargs e) { system.diagnostics.process.start("http://abcd/include/logoutpage.php"); this.close(); status = 0; try { conn.open(); string del = "delete mgen_validation_check md5values=@m"; mysqlcommand cmd2 = new mysqlcommand(del, conn); cmd2.parameters.addwithvalue("@m", qs); cmd2.executenonquery(); } catch (exception ex) { } { conn.close(); } } private void window_closed(object sender, eventargs e) { system.diagnostics.process.start("http://abcd/include/logoutpage.php"); try { conn.open(); string delconf = "delete mgen_validation_check md5values=@m"; mysqlcommand cmd3 = new mysqlcommand(delconf, conn); cmd3.parameters.addwithvalue("@m", docnum); cmd3.executenonquery(); } catch (exception ex) { } { conn.close(); } } } }
the app working except when running outlook becomes slow. other ms office apps working properly.
any helpful. in advance
Comments
Post a Comment