by
14
8
2,611
1
Top 1% !
Popular
Famous
Nice
Easy-to-find
Specified
Tuned
MultiPlatform
Popularity: 6515th place
.NETFramework3.5
ClassNameAnonWorker
InputName0begin
InputName1completed
InputName2progress
InputType0DoWorkEventHandler
InputType1RunWorkerCompletedEventHandler
InputType2ProgressChangedEventHandler
Languagec#
MethodNameExecute
OutputTypevoid
Target Framework3 - 4.5
threadingDynamic

ANonyMUs inLINe WERKuh C#

ILYNe exeKutin oF wutteva INda BaKGRownD..  SwEET
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/565759/ANonyMUs-inLINe-WERKuh-C-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
//run a worker like an anonymous function public class AnonWorker { private BackgroundWorker bw = new BackgroundWorker(); private AnonWorker(){ } public static AnonWorker Create { get { return new AnonWorker(); } } public void Execute(DoWorkEventHandler begin, RunWorkerCompletedEventHandler completed = null, ProgressChangedEventHandler progress = null) { bw.DoWork += begin; (completed != null) ? addComplete() : noop(); (progress != null) ? addProgress() : noop(); bw.RunWorkerAsync(); } private void noop() { // nada... } private void addComplete() { bw.RunWorkerCompleted += completed; } private void addProgress() { bw.ProgressChanged += progress; } } // Now..... run it like this and its gonna be on a separate thread AnonWorker.Create.Execute((sender, data) => { // work here .... }, (sender, data) => { // all done }); // Old Skool..... AnonWorker.Create.Execute(delegate { // work }, delegate { // done });
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus