VRC Pros Optical Color Sort Using Tasks

My team has had problems during autonomous in multiple occasions with picking up the wrong color rings. I believed that we could fix this with a optical sensor and a color sort. This method works 99% of the time and I have a perfect program for driver control. However, during autonomous, I cannot find a way to constantly check the color input of the ring. After asking local teams, I have determined that tasks have been a successful way of using color sort. Throughout my research on tasks, I have only determined what they do and not how to program them. Does anyone have a piece of example code for how to program a task? Or any experience or Advice? On another way to program color sort?