jueves, 27 de octubre de 2016

Nice and interesting video

I've discovered this video I think is just nice, due to the sound and the coordination between music and graphics.

jueves, 6 de octubre de 2016

Palying with BackgroundWorker class

In large web applications sometimes we need some async process. So I found the BackgroundWorker class

I've write a little example:




public class MainClass
{
 public static void Main (string[] args)
 {
  var process = new BackGroundProcess ();

  Console.WriteLine ("--start---");
  process.DoWork (new ProcessRequest{ Value = "1254879" });
  Console.WriteLine ("--end---");
  Console.ReadKey ();
 }
}

public class BackGroundProcess
{
 private readonly BackgroundWorker backGroundWorker;

 public BackGroundProcess ()
 {
  backGroundWorker = new BackgroundWorker ();
  backGroundWorker.WorkerSupportsCancellation = false;
 }

 public void DoWork(ProcessRequest request){
  backGroundWorker.DoWork += DoWork;
  backGroundWorker.RunWorkerAsync (request);
 }

 private void DoWork(object sender, 
  DoWorkEventArgs e)
 {   
  var param = e.Argument as ProcessRequest;
  Thread.Sleep (100);
  Console.WriteLine ("param: " + param.Value);
 }
}

public class ProcessRequest
{
 public string Value{ get; set;}
}
the output is:
--start---
--end---
param: 1254879