Fungus Gnats are usually a sign of high levels of moisture in the soil due to over watering. The adult gnats have a short lifespan of only 10-12 days but they lay their eggs in the uppermost layer of the potting medium where the larvae feed on decomposing matter in the soil before emerging as adults and the cycle continues.
Allowing longer drying intervals between watering should keep Fungus Gnats at bay but when using pesticides, take care to avoid exposure by wearing eye protection to prevent spray blowing into your eyes and gloves to prevent possible skin irritations.