Is it difficult in C# to block and unblock the internet connection on a pc?

If that's not too difficult, is it also possible to raise an event when an application wants to access the internet?

(Yes I want to built a basic firewall )

Cheers
PB