Grammatically, it's OK. However, the meaning seems a little odd. The sentence suggests a relationship between the two parts, yet it is not apparent what that relationship is.
eg it sounds a bit like your friend deliberately waited until you had finished your essay.