Thomas Gray belonged to the school of graveyard poetry, which was not actually a school but a sort movement born to gather the poets of 18th century who shared the same kind of poetry and expressed the passage to romanticism.
Beside Thomas Gray, other important pre-romantic poets were Robert Burns, Edward Young etc.
This type of poetry is known as graveyard poetry because of its its meditations on death and the transitoriness of life, its description of churchyard settings and its preoccupation with the macabre and the loneliness of the grave.
As a matter of fact these poets preferred gloomy atmospheres, darnkness, melancholy, had an interested in ruins and introduced a new type of hero, the dark hero: a romantic hero (who was anticipated by Shakespeare's Amleto) with a weak personality, doubts, uncertainties
A key word for these poets is sublime, a word that Edmund Burke examines in depth, in his work "Philosophical Enquiry into the Origin of Our Ideas of the Sublime and Beautiful", where he makes a comparison between the sublime which it's sort of "emotional" beauty and the greek beauty based on proportion and harmony.
Both the poets are neoclassic in the structure but the topic they both have is pre-romantic: they meditate about the value of life, death..
The difference lies in the fact that Foscolo talks about great personality as an inspiration, while Thoms Gray chooses humble people, such as the inhabitants of his small village.