Cook the mushrooms in a large frying pan with the butter on medium heat for 5 minutes, then add the ham and onion. Cook for 5 more minutes. Add the white wine and cook for 10 more minutes.
Add the crème fraiche to the mixture and mix well. Remove from heat.
Line a non-stick flan tin with one shortcrust pastry sheet and trim the edge. Pour the mixture in the pastry shell. Cover with the other shortcrust pastry sheet and trim, then press the edges together.
Brush with the beaten egg yolk, sprinkle with salt and fresh thyme. Slit the top sheet of pastry in a few places with a knife. Bake for 30 minutes and enjoy!