问题列表 - 第12468页

使用MDS使用SocketConnection与Blackberry进行问题

我目前正在Blackberry上编写一个应用程序来简单地发送和接收一些原始数据到我网络上的另一个基于TCP的设备.我在Blackberry模拟器中遇到同样的问题,MDS模拟器运行并使用物理电话与我公司的MDS服务器通信.请注意,直接使用wifi而不是通过MDS时不会发生此问题.

问题是InputStream上的available()函数返回零,除非我先调用read().如果我先调用read(知道有一些数据可用..谢谢wireshark),数据会回来,随后对available()的调用会指示我没有读取的数据.问题是我并不总是能保证数据会存在,所以我可以阻止.是否有人意识到这一点,这是一个问题或设计的东西?

是否有人知道一种方法来测试read()方法是否会在调用它们之前阻止它们可用?

这基本上就是我在做什么:

SocketConnection s = (SocketConnection)Connector.open("socket://1.2.3.4:port;deviceside=false", Connector.READ_WRITE);

OutputStream o = ((StreamConnection)s).openOutputStream();
InputStream i = ((StreamConnection)s).openInputStream();

o.write("hello");
Thread.sleep(sometime);
if (i.available() > 0) {
   byte[] data = new data[10];
   int bytesRead = i.read(data);
   System.out.println("Read [" + new String(data) + "] (bytes = " + bytesRead + ")");
}

我必须评论if条件是否有效.

sockets networking iostream blackberry mds-cs

5
推荐指数
1
解决办法
1258
查看次数

使用 Java 在 Windows 和 OS X 上保存程序配置文件的最佳位置?

我有一个在 Windows XP / Vista / 7 和 Mac OS X 上运行的 SWT Java 应用程序。我当前将配置文件保存到:

System.getProperty("user.home") + 文件名

随着 Windows Vista 和 Windows 7 中安全性的变化,这似乎不再是保存它的最佳位置。

该文件保存注册密钥信息等信息,如果该文件无法保存或被删除,我的用户会很烦恼。

我应该使用更好的路径吗?

另外,Mac OS X 上每个用户应用程序数据的首选路径是什么?

java filesystems file-io swt

5
推荐指数
1
解决办法
2175
查看次数

-1
推荐指数
2
解决办法
961
查看次数

ASP.NET私有成员字段在回发时丢失了值

请考虑以下代码:

    public partial class TeacherControlPanel : System.Web.UI.Page
    {
        protected string username = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            username = (string)Request.QueryString["username"];

            Ice_Web_Portal.BO.Teacher teacher = Ice_Web_Portal.BO.Teacher.GetTeacherByUsername(username);

            if (teacher != null)
            {
                labUsername.Text = username;
                labName.Text = teacher.TeacherName;
                labTeacherCode.Text = teacher.TeacherCode;

                Dept dept = teacher.Department;

                if (dept != null)
                {
                    labDepartment.Text = dept.DeptName;
                }
            }
            else
            {
                //labErrorMessage.Text = "No teacher found";
            }
        }

        protected void btnSendMail_Click(object sender, EventArgs e)
        {
            Response.Redirect(@"~/Teacher/TeacherComposeMail.aspx?username=mahabub" + username);            
        }
}
Run Code Online (Sandbox Code Playgroud)

在此代码中,当我将'username'声明为private时,在后续回发后将其初始化为null.

为什么?

秘密是什么?

asp.net postback

8
推荐指数
2
解决办法
1万
查看次数

gcc编译器的优势

谁能告诉我gcc是什么?而wts是其优于其他编译器的优势,如turbo c和visual c

compiler-construction gcc

3
推荐指数
1
解决办法
3771
查看次数

KVC/KVO和绑定:为什么我只收到一个更改通知?

我看到了Cocoa的KVC/KVO和绑定的一些古怪行为.我有一个NSArrayController对象,它的'content'绑定到一个NSMutableArray,我有一个控制器注册为该arrangedObjects属性的观察者NSArrayController.通过此设置,我希望每次修改阵列时都会收到KVO通知.但是,似乎KVO通知仅发送一次; 第一次修改数组.

我在Xcode中设置了一个全新的"Cocoa Application"项目来说明问题.这是我的代码:

BindingTesterAppDelegate.h

#import <Cocoa/Cocoa.h>

@interface BindingTesterAppDelegate : NSObject <NSApplicationDelegate>
{
    NSWindow * window;
    NSArrayController * arrayController;
    NSMutableArray * mutableArray;
}
@property (assign) IBOutlet NSWindow * window;
@property (retain) NSArrayController * arrayController;
@property (retain) NSMutableArray * mutableArray;
- (void)changeArray:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)

BindingTesterAppDelegate.m

#import "BindingTesterAppDelegate.h"

@implementation BindingTesterAppDelegate

@synthesize window;
@synthesize arrayController;
@synthesize mutableArray;

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
    NSLog(@"load");

    // create the array controller and the mutable array:
    [self setArrayController:[[[NSArrayController alloc] init] autorelease]]; …
Run Code Online (Sandbox Code Playgroud)

cocoa key-value-observing key-value-coding cocoa-bindings

2
推荐指数
2
解决办法
3756
查看次数

如何在转发器中执行if语句

<asp:Repeater> 让我发疯

我需要去做

<ItemTemplate>
    <% if (Container.DataItem("property") == "test") {%>
        I show this HTML
    <% } else { %>
        I show this other HTML
    <% } %>
</ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

但我无法为我的生活找到任何方法来实现这一目标.三元不是很好,因为HTML的数量非常大,通过DataBind事件设置标签也不是很好,因为我必须在代码隐藏中拥有大块的HTML.

当然有办法做到这一点....

c# if-statement repeater

6
推荐指数
2
解决办法
2万
查看次数

按值返回内联函数

我正在实现一些数学类型,我想优化运算符以最小化创建,销毁和复制的内存量.为了演示我将向您展示我的Quaternion实现的一部分.

class Quaternion
{
public:
    double w,x,y,z;

    ...

    Quaternion  operator+(const Quaternion &other) const;
}
Run Code Online (Sandbox Code Playgroud)

我想知道以下两个实现如何不同.我有一个+ =实现,可以在没有创建内存的情况下就地操作,但是一些使用四元数的高级操作对于使用+而不是+ =很有用.

__forceinline Quaternion Quaternion::operator+( const Quaternion &other ) const
{
    return Quaternion(w+other.w,x+other.x,y+other.y,z+other.z);
}
Run Code Online (Sandbox Code Playgroud)

__forceinline Quaternion Quaternion::operator+( const Quaternion &other ) const
{
    Quaternion q(w+other.w,x+other.x,y+other.y,z+other.z);
    return q;
}
Run Code Online (Sandbox Code Playgroud)

我的c ++完全是自学成才的,所以当谈到一些优化时,我不确定该怎么做,因为我不确切知道编译器如何处理这些事情.这些机制如何转换为非内联实现.

欢迎对我的代码提出任何其他批评.

c++ memory optimization inline

7
推荐指数
2
解决办法
3753
查看次数

Django - Mac OSX工作流程 - 有关高效开发方法的问题

我将概述我的工作流程,我想就如何提高效率提出一些建议.现在看起来有点麻烦和重复(我讨厌的东西),所以我正在寻找一些改进.请记住,我仍然是django的新手以及它是如何工作的但我是一个非常流利的编码器(恕我直言).所以这里......

工具(我每天都使用这些工具,所以我不倾向于转移):

  • Mac OSX Leopard
  • TextMate的
  • 终端带标签
  • Perforce公司

假设

  • Django Basics(教程/买书)
  • Python Fluent(运行2.6,支持IDLE)
  • 开始我的第一个应用程序在models.py上工作

开始

  • 创建一个TextMate项目,其中包含整个django树.

TextMate项目http://img.skitch.com/20090821-g48cpt38pyfwk4u95mf4gk1m7d.jpg

  • 在终端的第一个选项卡中启动服务器

    python ./manage.py runserver

  • 在终端窗口的第二个选项卡中启动shell

    python ./manage.py shell

  • 这产生了iPython,让我开始开发工作流程

工作流程

  • 创建并构建一个名为models.py的基本模型

  • 建立一个基本模型


class P4Change(models.Model):
  """This simply expands out 'p4 describe' """
  change        = models.IntegerField(primary_key=True)
  client        = models.ForeignKey(P4Client)
  user          = models.ForeignKey(P4User)
  files         = models.ManyToManyField(P4Document)
  desc          = models.TextField()
  status        = models.CharField(max_length=128)
  time          = models.DateField(auto_now_add=True)


  def __unicode__(self):
    return str(self.change)

admin.site.register(P4Change)
Run Code Online (Sandbox Code Playgroud)
  • 在第一个终端(运行服务器)中停止它^ C和syncdb启动服务器

>  python ./manage.py syncdb
Creating table perforce_p4change
Installing index for …
Run Code Online (Sandbox Code Playgroud)

django macos workflow textmate

5
推荐指数
1
解决办法
2912
查看次数

C# - 委托System.Func <>

如何使用委托System.Func <>?我们应该使用它控制funcion或事件的执行顺序吗?

简单的例子会有所帮助

c#

17
推荐指数
2
解决办法
2万
查看次数