Heres Swift 3 версия
let whitespaceSet = NSCharacterSet.whitespaces
let range = string.rangeOfCharacter(from: whitespaceSet)
if let _ = range {
return false
}
else {
return true
}
You can always store this information for yourself in a suitable data structure. Use a hash or a map to map GetThreadId() to this name. Since GetThreadId() is always a unique identifier, this works just fine.
Cheers !
Of course, if he's creating many threads, that hashmap will slowly fill up and use more and more memory, so some cleanup procedure is probably a good thing as well.
You're absolutely right. When a thread dies, it's corresponding entry in the map should naturally be removed.
Это помогает? Как: задать имя потока в собственном коде
В управляемом коде это так же просто, как установить свойство Name соответствующего объекта потока.
Если вы хотите увидеть имя вашего потока в отладчике (windbg или Visual Studio): http://blogs.msdn.com/stevejs/archive/2005/12/19/505815.aspx
На самом деле я не уверен, есть ли обратный метод для получения имени потока. Но похоже, что TLS - правильный путь.