c# - Getting error called constructor has been deprecated -
when changed .net target framework 4.5 framework 4.0. getting error in 1 line run
>>> system.threading.tasks.task.run(() => { printfactory.sendtexttolpt1(strprint); });
what reason this??
my code snippet:
private void button4_click(object sender, eventargs e) { //string filepath = image_print(); // messagebox.show(filepath, "path"); string newfilepath = image_print(); string strtext = string.empty; using (streamreader stream = new streamreader(newfilepath)) { strtext = stream.readtoend(); stream.close(); } string strprint = strtext + print_image(); if (string.isnullorempty(strprint) || string.isnullorempty(img_path.text)) { return; } else { sendfile.image splash = new sendfile.image(); this.hide(); splash.show(); system.threading.tasks.task.run(() => { printfactory.sendtexttolpt1(strprint); }); //<<< here getting error in run splash.formclosed += delegate { system.io.file.delete(newfilepath); this.show(); }; } }
system.threading.tasks.task.run
not exist in .net 4.0. need utilize task.factory.startnew
:
system.threading.tasks.task.factory.startnew(() => { printfactory.sendtexttolpt1(strprint); });
c# wpf
No comments:
Post a Comment