What is going on with that . . . ?

I can be at work at my day job, working along on something tedious that also requires a great deal of focus, when -- occasionally -- i am overwhelmed with the urge to close my eyes. 

When I do this I am not exactly asleep, but I do have flashes of weird, random, dream-like thoughts that have absolutely nothing to do with the task I am performing.  This lasts for a matter of a few seconds, until I realize what is going on. 

On some days, it happens frequently, throughout the workday.

I have experienced this phenomenon for a number of years, and it is really aggravating.  I have find plenty of "stuff" on the Internet about unrelated issues, but nothing that directly speaks to this.  

Can someone help me put a finger on what is going on, or at least point me toward an accurate resource to explore further? 

Is it merely a lack of sleep, or something else?  

Thanks. 

I wish I knew William - I've had it all my life, even when I was in primary school! I suspect it may have something to do with the quality of our sleep, possibly sleep apnoea.

Have you tried asking your doctor if you can be referred to a sleep clinic? You might stand some chance of this as a male. Unfortunately, females don't "officially" suffer from sleep apnoea, so can't be referred for a sleep study in most countries.

All I can say is that it's limited my life a bit but has never affected my general health. I'm 73 now and apart from an annoying autoimmune condition, I'm in very good health.

Hypnagogic hallucinations.you can Google it.

I experience something similar: a sudden weariness while working on emails or other screen matters or reading a newspaper.  Fortunately I am retired. I tried resisting it but now I just go and lie on my bed and immediately fall asleep for 30 or so minutes.  I wake and am fully refreshed until the next bout of weariness.  My GP and my neurologist both say it is because I am getting older (in my mid 70s), and to try to go to bed earlier (c 21.00) and sleep longer in the morning.  I am trying to do that but not much effect so far.