distance sensor and timing

I am just a beginner at programming and I am not aware how to make it non blocking.