title: Grand Central Dispatch problems with dispatch_release
body: <p>I have a problem with a GCD solution I've made. I have a thread that runs in the background, it updates the application in a given interval. For this I use a timer.</p>
  
  <p>However if the user wants to change this interval, I call</p>
  
  <pre><code>dispatch_source_cancel(timer);
  </code></pre>
  
  <p>Which is defined as</p>
  
  <pre><code>dispatch_source_set_cancel_handler(timer, ^{
     dispatch_release(timer);
  });
  </code></pre>
  
  <p>And then restart the the thread. When the interval is changed a second time the app crashes. Even though I do recreate the timer with a new interval.</p>
  
  <p>I could avoid releasing the timer, but then I'll have memory leeks.</p>
  
  <p>Any advice, what to do?</p>
  
  <p>EDIT:
  Timer is created like this</p>
  
  <pre><code>timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER,0,0, autoRefreshQueue);
  
  if(!timer) {
      return;
  }
  
  dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, refreshRate * NSEC_PER_SEC), refreshRate * NSEC_PER_SEC, refreshRate * NSEC_PER_SEC);
  dispatch_source_set_event_handler(timer, ^{
      //do work
  });
  </code></pre>