Heat the oven to 190C/fan 170C/gas 5. Roll out the pastry and line a 23cm tart tin. Line with paper and fill with baking beans then blind bake for 15 minutes. Remove the paper and beans and cook for another 10 minutes. Cook the onions in the butter over a low heat until caramelised, this will take about 30 minutes so be patient. Mix the cream, eggs, gruyère and thyme, and season. Stir in the onions. Pour into the tart case. Sprinkle over the parmesan. Cook for 20-25 minutes until just set. Serve at room temperature.