How to contact a foreign professor and ask him to cooperate in a research work?
Can I apply to the same professor for a Ph.D. position who I am going to work with him on this project?

Yes, at least at US institutions this would not be a problem. I don't know of any reason why it might be problematic anywhere else.

Is it constructive and has a positive effect on my application process? If yes, could you please tell me how can I explain the situation to a professor to persuade him to work with me. I mean let me know how can I take the advantage of this project on my application process.

As I mentioned in my comment above, it's often an advantage to have previously contacted a potential advisor and discussed working with them. Many prospective graduate students &quot;cold email&quot; professors to express interest in working with them, discuss potential research projects and--usually the primary reason for emailing--to make sure the professor recognizes their name and remembers them when actually reviewing applications.
Having a particular topic or project in mind tends to be a positive--as long as it's something the department or professor you're applying to work with is interested in. The only downside to having a specific project in mind is that it might be limiting if the professor isn't interested in it and you haven't expressed any interest in things they DO want a student to work on. That seems unlikely if you're selecting them as a potential collaborator because their work aligns with your project, but I'd make sure to explicitly state that while you want to work on this project, you are also interested in ___ (things that they study that you would be interested in doing for your PhD--read their webpage to get an idea of their broader research interests and ongoing projects).
In general, when emailing potential advisors/collaborators, keep the following rules in mind:

Be polite and respectful! Don't ever come off as arrogant/demanding/expectant.
Mention who you've worked with--you'll gain credibility if they know your advisor, respect your institution, etc..
Demonstrate that you've done some background research into what they do--mention work they've done that interests you, papers you particularly liked, etc.
What can you offer to them or their lab? Describe your background, strengths, interests, etc... show them (without being arrogant!) why you think working with you/taking you on as a student would be worth their time.
Show your enthusiasm!
Try to keep it as brief as possible while still including all relevant information--be succinct. Professor are extremely busy and get about a zillion emails a day. He/she will probably not bother reading your email if it's super long. Also on this note, make sure you include enough info to snag their attention in the first few lines, since that may be all they read if they aren't hooked by then.

An example email would be something like the following (reorganized/worded as needed):

Hi Professor ___,
I'm currently finishing my Msc. degree at [institution] with [your current Professor], and am planning to pursue a PhD in [field] this coming [whenever you'll be applying]. My thesis work has been on [describe your research].
I'm contacting you for two reasons: first, I'm considering applying to [institution], and was wondering if you are currently accepting new PhD students. I'm especially excited about your work in [topics], and [describe any particular topics where your interests intersect with his/her research, strengths you have that would be particularly helpful in pursuing this/these avenues of research, etc.--e.g., I think my background/experience in __ would be an asset in studying __].
Second, one of the outcomes of my thesis work is [describe your ongoing project], which I would like to work on as a [side project/chapter/Phd project/etc. depending on the scope of what you have in mind]. We have 1 year of funding to complete this [maybe include more details--mentioning the funding is very important since it means you come with support!], and are currently looking for collaborators to [describe what you need them to help with]. [Explain why you think he/she would be the perfect collaborator].
I'd love to discuss potential PhD research topics and collaborating on our __ work if you have time in the next [give them a reasonable but discrete timeframe--few weeks is usually good].
Thank you for your time,
Arash