static void Main(string[] args) { var cancellationToken = CancellationToken.None; var pullo = new Pullo() .WithMaxDegreeOfParallelism(2) .With(cancellationToken) .WithTimeout(TimeSpan.FromHours(1), 5); pullo.OnStart((state, action) => Console.WriteLine("Action Started")); pullo.OnSuccess((state, action) => Console.WriteLine("Action Successful")); pullo.OnError((state, action, e) => Console.WriteLine("Action Errored {0}", e.Message)); pullo.Enqueue(token => Console.WriteLine("Hello Task Enqueue 1!")); pullo.Enqueue(token => Console.WriteLine("Hello Task Enqueue 2!")); pullo.Run(new List <Action <CancellationToken> > { token => Console.WriteLine("Hello Task One!"), token => Console.WriteLine("Hello Task 2!"), token => Console.WriteLine("Hello Task 3!"), token => Console.WriteLine("Hello Task 4!") }); pullo.StartAndWait(); //Start running the jobs, and wait for new jobs until Done() or Stop() is called //pullo.IsCompleted // all jobs are completed and .Done() is called //pullo.Done(); // Marks the pullo instances as not accepting any more additions //pullo.Size(); // Size of queue //pullo.Stop(); // Stop processing and cancel all jobs Console.WriteLine("Hello pullo!"); }
private void OnCollisionEnter(Collision otherCol) { if (otherCol.gameObject.CompareTag("omena") || otherCol.gameObject.CompareTag("paaryna")) { spawner.DestroyApple(otherCol.gameObject, Smash); } else if (otherCol.gameObject.CompareTag("JOUTSEN")) //if posautin hits a joutsen { otherCol.gameObject.GetComponentInChildren <ParticleSystem>(true).gameObject.SetActive(true); Destroy(otherCol.gameObject.GetComponentInChildren <ParticleSystem>().gameObject, 10); //taikaa for (int i = 0; i < otherCol.transform.childCount; i++) { if (!otherCol.transform.GetChild(i).GetComponent <ParticleSystem>()) { Destroy(otherCol.transform.GetChild(i).gameObject); } } otherCol.transform.DetachChildren(); Destroy(otherCol.transform.gameObject); } else if (otherCol.gameObject.CompareTag("korkki")) { Pullo.DisableCork(); otherCol.transform.parent = null; otherCol.gameObject.GetComponent <Rigidbody>().useGravity = true; otherCol.gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; otherCol.gameObject.GetComponent <Rigidbody>().AddForce(Vector3.up * 2, ForceMode.Impulse); } if (gameObject.CompareTag("Bullet")) { if (otherCol.gameObject.isStatic) { GameObject dec = Instantiate(decal, otherCol.GetContact(0).point, Quaternion.identity); //dec.transform.rotation = Quaternion.FromToRotation(transform.up, otherCol.GetContact(0).normal); dec.transform.Translate(0, 0.01f, 0); dec.GetComponent <decal>().Orient(); } Destroy(gameObject); } }