`DispatchQueue.main` inside Network Extension

While debugging NEPacketTunnelProvider I found that it's startTunnel and stopTunnel are being run not on the first thread. The question is can I use DispatchQueue.main in Network Extensions? Are there any things to watch out for when dealing with async code inside Network Extensions?

The question is can I use DispatchQueue.main in Network Extensions?

Why are you wanting to control the queue in which this work is being run on?

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

I'd like to make so API calls in the background and then get back to original thread, for example.

What if you used a provider specific work queue and sent your work there, then everything else was run on the thread that ran the provider specific functions? Something like:

let queue = DispatchQueue(label: "NEPacketTunnelProvider", autoreleaseFrequency: .workItem)

...

self.queue.async {
	// Do some work
}

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
`DispatchQueue.main` inside Network Extension
 
 
Q