It's happened to me twice last summer while touring Europe- first time was ascending the Stelvio Pass up the hard way, I got stuck in gear halfway up. When I got to the top, I stopped to take a look, could see no obvious external problems, and when it started snowing thought it best to get down the other side and check it out in Bormio, but after 10 minutes of rest, the gearbox suddenly worked again. I had the bike checked out in Agostinis but the mechanic could find nowt wrong with it.
On the way home, after being stuck in a very hot traffic jam in Zurich city centre it happen again. Stopped by the roadside to let it cool down- and 10 mins later she was fine.
I am wondering whether it was something to do with hydaulics- have not changed the fluid for a while.