Feature activation could be performed two completely different ways:
- Through GUI - in this case you have HttpContext, SPContext and all other stuff ready for you and SPLongOperation will work
- By using stsadm or PowerShell - in this case you don't have anything of above and obviously SPLongOperation will not work (DotPeek also shows it depends on HttpContext).
You can determine which scenario you're running simply by comparing HttpContext.Current to null
.
For the stsadm/PS scenario, you can consider creating a separate timer job or something like this. For GUI, you are able to use SPLongOperation and redirect to the "Site Features" or "Site Collection Features" page after it finishes, depending of which scope you're using for the feature. The redirection url will be /_layouts/ManageFeatures.aspx?Scope=Web
or /_layouts/ManageFeatures.aspx?Scope=Site
correspondingly.
P.S. I don't have any real experience of using SPLongOperation from within feature receiver, but I have experience of determining the GUI/stsadm from within feature for some other purposes.