か~ないかのうちに is a slightly formal grammar structure used in Japanese to indicate a precise point in time where the action of (A) can not be determined as either being started, or finished. Usually, it highlights the exact moment either before or after (A) commences. This grammar structure is comprised of か, ない, か, の, the noun 内(うち) 'within', and に. Literally, it just means 'while not knowing whether (A) or not (A), (B)'.
The verb that appears before か and ないか must be repeated in this grammar pattern, and may be used in its dictionary form. Standard translations include 'right after (A)', 'as soon as (A)', and 'barely when (A)'.
父(ちち)はビールを飲(の)み終(お)わるか飲(の)み終(お)わらないかのうちに、新(あたら)しい缶(かん)を開(あ)けた。
My father opened a new can of beer as soon as he finished his beer.
彼(かれ)は椅子(いす)に座(すわ)るか座(すわ)らないかのうちに、テレビをつけた。
He turned his TV on just as he sat down.
彼女(かのじょ)は車(くるま)が止(と)まるか止(と)まらないかのうちに、ドアを開(あ)けて駅(えき)へと走(はし)っていった。
Just as the car stopped, she opened the door and ran to the station.
Additionally,
か~ないかのうちに may be used to highlight relatively short periods of time within which something happens. This is usually in regard to some sort of positive or negative occurrence that would not usually be expected to be able to happen so quickly.
就活(しゅうかつ)を初(はじ)めて1週間(しゅうかん)経(た)つか経(た)たないかのうちに、仕事(しごと)が見(み)つかった。
In just a week of looking for a new job, I found a job.
戦争(せんそう)が終(お)わるか終(お)わらないかのうちに、原爆(げんばつ)が落(お)とされた。
An atomic bomb was dropped, just when the war was about to end.