在本文中,我们将带你了解C#:Process.HasExited返回false,即使进程已终止在这篇文章中,我们将为您详细介绍C#:Process.HasExited返回false,即使进程已终止的方
在本文中,我们将带你了解C#:Process.HasExited返回false,即使进程已终止在这篇文章中,我们将为您详细介绍C#:Process.HasExited返回false,即使进程已终止的方方面面,并解答process.waitfor返回1常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的04: Job for docker.service failed because the control process exited with error code 解决、android – Bitmap.compress为绘制的图像返回false、android – Geocoder的isPresent()方法总是返回false、angularjs – NodeJs Passport isAuthenticated()返回false即使在登录后。
本文目录一览:- C#:Process.HasExited返回false,即使进程已终止(process.waitfor返回1)
- 04: Job for docker.service failed because the control process exited with error code 解决
- android – Bitmap.compress为绘制的图像返回false
- android – Geocoder的isPresent()方法总是返回false
- angularjs – NodeJs Passport isAuthenticated()返回false即使在登录后
C#:Process.HasExited返回false,即使进程已终止(process.waitfor返回1)
我在一个进程上调用了Kill(),它似乎已经退出了.但是当我测试HasExited时,我得到了错误:
myProcess.Kill(); while ( !myProcess.HasExited ) { Thread.Sleep(1000); }
这将持续无限期.当然,我必须更改此代码以最终停止等待,但我很好奇为什么HasExited仍然返回false,因为这个过程似乎从地图上掉了下来.
解决方法
When standard output has been redirected to asynchronous event handlers,it is possible that output processing will not have completed when this property returns true. To ensure that asynchronous event handling has been completed,call the WaitForExit() overload that takes no parameter before checking HasExited.
无论如何,建议的解决方法应该可以做到这一点:
myProcess.Kill(); myProcess.WaitForExit();
04: Job for docker.service failed because the control process exited with error code 解决
Job for docker.service failed because the control process exited with error code 解决
Job for docker.service failed because the control process exited with error code
这个一般是由于 /etc/docker/daemon.json 里面配置有误
正确配置例子
[root@k8s129 v2]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://aeckruos.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.6.129:5000"]
}
逗号不能漏
切记切记。。。。。每行是有一个,号作为分隔符。
android – Bitmap.compress为绘制的图像返回false
我有一些代码,用户在屏幕上绘制内容,我想将其作为PNG存储在byte []中.但是,compress()方法返回false.知道为什么会这样吗?是否有更好的方法来获取byte []?
Bitmap bm = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ALPHA_8);
Canvas c = new Canvas(bm);
c.drawPath(mSignaturePath, mSignaturePaint);
ByteArrayOutputStream out = new ByteArrayOutputStream();
if (bm.compress(Bitmap.CompressFormat.PNG, 100, out)) {
byte[] result = out.toByteArray(); // Never gets called
}
提前致谢.
解决方法:
问题在于我是如何创建图像的:
Bitmap bm = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ALPHA_8);
当我将其更改为Bitmap.Config.RGB_565时,它运行正常.
感谢Mark Murphy(@commonsware)在办公时间提供建议!
android – Geocoder的isPresent()方法总是返回false
类:
public class LocationTestActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); Log.d( "LocationTestActivity","Geocoder.isPresent : " + Geocoder.isPresent() ); } }
AndroidManifest.xml在“application”元素之前还有以下条目:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
环境:Eclipse Indigo 3.7.1,XP Professional 2002 SP 3上的ICS 4.0仿真器
请帮我理解:
1.为什么Geocoder.isPresent()总是假装错误?
2.要进行哪些更改以便Geocoder.isPresent()返回true?
非常感谢!
解决方法
Geocoder
需要一个由框架在后台运行的服务.
从文档:
The Geocoder query methods will return an empty list if there no
backend service in the platform. Use the isPresent() method to
determine whether a Geocoder implementation exists.
因此,如果我们查看isPresent()
的文档,它就说明了.
Returns true if the Geocoder methods getFromLocation and
getFromLocationName are implemented. Lack of network connectivity may
still cause these methods to return null or empty lists.
注意:请记住isPresent()在Pre-Api 9平台中不可用.
angularjs – NodeJs Passport isAuthenticated()返回false即使在登录后
app.post(‘/ login’,…..)在响应中返回用户,但在加载管理页面之后,它将检查用户是否通过调用app.get(‘/ loggedin’)登录. ..)和req.isAuthenticated()即使在登录后也返回false,它进入一个循环.我不明白为什么这是发生在帮助我.
服务器端代码
var express = require('express'); var http = require('http'); var path = require('path'); var passport = require('passport'); var LocalStrategy = require('passport-local').Strategy; //================================================================== // Define the strategy to be used by PassportJS passport.use(new LocalStrategy( function(username,password,done) { if (username === "admin" && password === "admin") // stupid example return done(null,{name: "admin"}); return done(null,false,{ message: 'Incorrect username.' }); } )); // Serialized and deserialized methods when got from session passport.serializeUser(function(user,done) { done(null,user); }); passport.deserializeUser(function(user,user); }); // Define a middleware function to be used for every secured routes var auth = function(req,res,next){ if (!req.isAuthenticated()) res.send(401); else next(); }; //================================================================== // Start express application var app = express(); // all environments app.set('port',process.env.PORT || 3000); app.use(express.favicon()); app.use(express.cookieParser()); app.use(express.bodyParser()); app.use(express.methodoverride()); app.use(express.session({ secret: 'securedsession' })); app.use(passport.initialize()); // Add passport initialization app.use(passport.session()); // Add passport initialization app.use(app.router); app.all('*',function(req,next) { res.header("Access-Control-Allow-Origin","*"); res.header("Access-Control-Allow-Headers","Origin,X-Requested-With,Content-Type,Accept"); next(); }); // development only if ('development' == app.get('env')) { app.use(express.errorHandler()); } //================================================================== // routes app.get('/',res){ res.render('index',{ title: 'Express' }); }); app.get('/users',auth,res){ res.send([{name: "user1"},{name: "user2"}]); }); //================================================================== //================================================================== // route to test if the user is logged in or not app.get('/loggedin',res) { res.send(req.isAuthenticated() ? req.user : '0'); }); // route to log in app.post('/login',passport.authenticate('local'),res) { res.send(req.user); }); // route to log out app.post('/logout',res){ req.logout(); res.send(200); }); //================================================================== http.createServer(app).listen(app.get('port'),function(){ console.log('Express server listening on port ' + app.get('port')); });
客户端Js文件
'use strict'; /********************************************************************** * Angular Application **********************************************************************/ var app = angular.module('app',['ngResource','ngRoute']) .config(function($routeProvider,$locationProvider,$httpProvider) { //================================================ // Check if the user is connected //================================================ var checkLoggedin = function($q,$timeout,$http,$location,$rootScope){ // Initialize a new promise var deferred = $q.defer(); // Make an AJAX call to check if the user is logged in $http.get('http://localhost:3000/loggedin').success(function(user){ // Authenticated if (user !== '0') $timeout(deferred.resolve,0); // Not Authenticated else { $rootScope.message = 'You need to log in.'; $timeout(function(){deferred.reject();},0); $location.url('/login'); } }); return deferred.promise; }; //================================================ //================================================ // Add an interceptor for AJAX errors //================================================ $httpProvider.responseInterceptors.push(function($q,$location) { return function(promise) { return promise.then( // Success: just return the response function(response){ return response; },// Error: check the error status to get only the 401 function(response) { if (response.status === 401) $location.url('/login'); return $q.reject(response); } ); } }); //================================================ //================================================ // Define all the routes //================================================ $routeProvider .when('/',{ templateUrl: 'views/main.html' }) .when('/admin',{ templateUrl: 'views/admin.html',controller: 'AdminCtrl',resolve: { loggedin: checkLoggedin } }) .when('/login',{ templateUrl: 'views/login.html',controller: 'LoginCtrl' }) .otherwise({ redirectTo: '/login' }); //================================================ }) // end of config() .run(function($rootScope,$http){ $rootScope.message = ''; // logout function is available in any pages $rootScope.logout = function(){ $rootScope.message = 'Logged out.'; $http.post('http://localhost:3000/logout'); }; }); /********************************************************************** * Login controller **********************************************************************/ app.controller('LoginCtrl',function($scope,$rootScope,$location) { // This object will be filled by the form $scope.user = {}; // Register the login() function $scope.login = function(){ $http.post('http://localhost:3000/login',{ username: $scope.user.username,password: $scope.user.password,}) .success(function(user){ // No error: authentication OK $rootScope.message = 'Authentication successful!'; $location.url('/admin'); }) .error(function(){ // Error: authentication Failed $rootScope.message = 'Authentication Failed.'; $location.url('/login'); }); }; }); /********************************************************************** * Admin controller **********************************************************************/ app.controller('AdminCtrl',$http) { // List of users got from the server $scope.users = []; // Fill the array to display it in the page $http.get('http://localhost:3000/users').success(function(users){ for (var i in users) $scope.users.push(users[i]); }); });
在快递
res.header('Access-Control-Allow-Credentials',true);
并在ajax设置
xhrFields: { withCredentials: true }
您可以找到相关的答案here和here
我们今天的关于C#:Process.HasExited返回false,即使进程已终止和process.waitfor返回1的分享已经告一段落,感谢您的关注,如果您想了解更多关于04: Job for docker.service failed because the control process exited with error code 解决、android – Bitmap.compress为绘制的图像返回false、android – Geocoder的isPresent()方法总是返回false、angularjs – NodeJs Passport isAuthenticated()返回false即使在登录后的相关信息,请在本站查询。
本文标签: