c# - How can I use Delay method and await? -
i want sequence in program take break while before going ahead next operation. this:
string s = hd.text; if (s.contains("php")||s.contains("echo")) { hd.text = "this okay ?"; messagebox.show("its php ?","gus"); }
i tried this:
if (s.contains("php")||s.contains("echo")) { hd.text = "this php ?"; task.delay(timespan.fromseconds(10)); messagebox.show("its php ?","guss"); }
but doesn't work. it's throwing exception below:
cannot find type system.resources.resourceset in module mscorlib.dll
as servy saying, need await task this:
solution 1:
public async task do() { if (s.contains("php")||s.contains("echo")) { hd.text = "this php ?"; await task.delay(timespan.fromseconds(10)); messagebox.show("its php ?","guss"); } }
or wait task this.
solution 2:
public void do() { if (s.contains("php")||s.contains("echo")) { hd.text = "this php ?"; task.delay(timespan.fromseconds(10)).wait(); messagebox.show("its php ?","guss"); } }
Comments
Post a Comment