Get unique ID for a running process












0















I'm currently looking to replace a system I've previously implemented that generates a unique id that is valid from when the process opens until when it closes, a random unique ID is generated using a mix of system time and other variables each time the application is started.



What I'm looking to do is generate a unique identifier for the process itself, the Process ID isn't something I can use as it's possible that it's reused



Does anyone know of a way to generate a unique id for a single process based on the process itself?










share|improve this question


















  • 3





    Could you use a guid? That would most likely be unique.

    – JLe
    Nov 23 '18 at 9:33











  • Yes, it would, what I need though is something that I can continually generate within the same session that has the same ID, simply based on the Process.

    – Dan Hall
    Nov 23 '18 at 9:57






  • 1





    What about using combining the process PID with the number of ticks picked from datetime.Now ? Or total seconds from epoch, depending of your process creation rate ?

    – Larry
    Nov 23 '18 at 10:05











  • How these IDs are used?

    – Dennis
    Nov 23 '18 at 11:01











  • @DanHall Why? This looks like an XY problem.

    – Ondrej Tucny
    Nov 23 '18 at 11:01
















0















I'm currently looking to replace a system I've previously implemented that generates a unique id that is valid from when the process opens until when it closes, a random unique ID is generated using a mix of system time and other variables each time the application is started.



What I'm looking to do is generate a unique identifier for the process itself, the Process ID isn't something I can use as it's possible that it's reused



Does anyone know of a way to generate a unique id for a single process based on the process itself?










share|improve this question


















  • 3





    Could you use a guid? That would most likely be unique.

    – JLe
    Nov 23 '18 at 9:33











  • Yes, it would, what I need though is something that I can continually generate within the same session that has the same ID, simply based on the Process.

    – Dan Hall
    Nov 23 '18 at 9:57






  • 1





    What about using combining the process PID with the number of ticks picked from datetime.Now ? Or total seconds from epoch, depending of your process creation rate ?

    – Larry
    Nov 23 '18 at 10:05











  • How these IDs are used?

    – Dennis
    Nov 23 '18 at 11:01











  • @DanHall Why? This looks like an XY problem.

    – Ondrej Tucny
    Nov 23 '18 at 11:01














0












0








0


0






I'm currently looking to replace a system I've previously implemented that generates a unique id that is valid from when the process opens until when it closes, a random unique ID is generated using a mix of system time and other variables each time the application is started.



What I'm looking to do is generate a unique identifier for the process itself, the Process ID isn't something I can use as it's possible that it's reused



Does anyone know of a way to generate a unique id for a single process based on the process itself?










share|improve this question














I'm currently looking to replace a system I've previously implemented that generates a unique id that is valid from when the process opens until when it closes, a random unique ID is generated using a mix of system time and other variables each time the application is started.



What I'm looking to do is generate a unique identifier for the process itself, the Process ID isn't something I can use as it's possible that it's reused



Does anyone know of a way to generate a unique id for a single process based on the process itself?







c# uniqueidentifier






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 9:25









Dan HallDan Hall

6271622




6271622








  • 3





    Could you use a guid? That would most likely be unique.

    – JLe
    Nov 23 '18 at 9:33











  • Yes, it would, what I need though is something that I can continually generate within the same session that has the same ID, simply based on the Process.

    – Dan Hall
    Nov 23 '18 at 9:57






  • 1





    What about using combining the process PID with the number of ticks picked from datetime.Now ? Or total seconds from epoch, depending of your process creation rate ?

    – Larry
    Nov 23 '18 at 10:05











  • How these IDs are used?

    – Dennis
    Nov 23 '18 at 11:01











  • @DanHall Why? This looks like an XY problem.

    – Ondrej Tucny
    Nov 23 '18 at 11:01














  • 3





    Could you use a guid? That would most likely be unique.

    – JLe
    Nov 23 '18 at 9:33











  • Yes, it would, what I need though is something that I can continually generate within the same session that has the same ID, simply based on the Process.

    – Dan Hall
    Nov 23 '18 at 9:57






  • 1





    What about using combining the process PID with the number of ticks picked from datetime.Now ? Or total seconds from epoch, depending of your process creation rate ?

    – Larry
    Nov 23 '18 at 10:05











  • How these IDs are used?

    – Dennis
    Nov 23 '18 at 11:01











  • @DanHall Why? This looks like an XY problem.

    – Ondrej Tucny
    Nov 23 '18 at 11:01








3




3





Could you use a guid? That would most likely be unique.

– JLe
Nov 23 '18 at 9:33





Could you use a guid? That would most likely be unique.

– JLe
Nov 23 '18 at 9:33













Yes, it would, what I need though is something that I can continually generate within the same session that has the same ID, simply based on the Process.

– Dan Hall
Nov 23 '18 at 9:57





Yes, it would, what I need though is something that I can continually generate within the same session that has the same ID, simply based on the Process.

– Dan Hall
Nov 23 '18 at 9:57




1




1





What about using combining the process PID with the number of ticks picked from datetime.Now ? Or total seconds from epoch, depending of your process creation rate ?

– Larry
Nov 23 '18 at 10:05





What about using combining the process PID with the number of ticks picked from datetime.Now ? Or total seconds from epoch, depending of your process creation rate ?

– Larry
Nov 23 '18 at 10:05













How these IDs are used?

– Dennis
Nov 23 '18 at 11:01





How these IDs are used?

– Dennis
Nov 23 '18 at 11:01













@DanHall Why? This looks like an XY problem.

– Ondrej Tucny
Nov 23 '18 at 11:01





@DanHall Why? This looks like an XY problem.

– Ondrej Tucny
Nov 23 '18 at 11:01












1 Answer
1






active

oldest

votes


















0














Process.StartTime.Ticks can be used an unique identifier because its impossible to run more than a process in a single tick






share|improve this answer



















  • 1





    Technically it's possible on a multicore CPU

    – phuclv
    Mar 27 at 1:54











  • if we are talking about possibilities then add process id asa a prefix to that uniuq identifier string :)

    – snoopcommands
    Mar 27 at 3:40












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443830%2fget-unique-id-for-a-running-process%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Process.StartTime.Ticks can be used an unique identifier because its impossible to run more than a process in a single tick






share|improve this answer



















  • 1





    Technically it's possible on a multicore CPU

    – phuclv
    Mar 27 at 1:54











  • if we are talking about possibilities then add process id asa a prefix to that uniuq identifier string :)

    – snoopcommands
    Mar 27 at 3:40
















0














Process.StartTime.Ticks can be used an unique identifier because its impossible to run more than a process in a single tick






share|improve this answer



















  • 1





    Technically it's possible on a multicore CPU

    – phuclv
    Mar 27 at 1:54











  • if we are talking about possibilities then add process id asa a prefix to that uniuq identifier string :)

    – snoopcommands
    Mar 27 at 3:40














0












0








0







Process.StartTime.Ticks can be used an unique identifier because its impossible to run more than a process in a single tick






share|improve this answer













Process.StartTime.Ticks can be used an unique identifier because its impossible to run more than a process in a single tick







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 1:49









snoopcommandssnoopcommands

1357




1357








  • 1





    Technically it's possible on a multicore CPU

    – phuclv
    Mar 27 at 1:54











  • if we are talking about possibilities then add process id asa a prefix to that uniuq identifier string :)

    – snoopcommands
    Mar 27 at 3:40














  • 1





    Technically it's possible on a multicore CPU

    – phuclv
    Mar 27 at 1:54











  • if we are talking about possibilities then add process id asa a prefix to that uniuq identifier string :)

    – snoopcommands
    Mar 27 at 3:40








1




1





Technically it's possible on a multicore CPU

– phuclv
Mar 27 at 1:54





Technically it's possible on a multicore CPU

– phuclv
Mar 27 at 1:54













if we are talking about possibilities then add process id asa a prefix to that uniuq identifier string :)

– snoopcommands
Mar 27 at 3:40





if we are talking about possibilities then add process id asa a prefix to that uniuq identifier string :)

– snoopcommands
Mar 27 at 3:40




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443830%2fget-unique-id-for-a-running-process%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini