Perhaps a code sample will be helpful, however there are many ways to avoid that, i.e. using statics or singleton pattern or checking for stuff before entering a code block.
Please Mark Post that helped you as answer, also include a summary of what solved the problem as it helps others in similar situations