单项选择题

______ in the queue for half an hour, Tom suddenly realized that he had left his wallet at home.

A. To wait
B. Waiting
C. Having waited
D. To have waited